![[C#] 11일차 - 70. 세개의 숫자중 가장 큰 수를 찾는 정적 메소드](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FoXjj4%2FbtqVcrijbHW%2FAAAAAAAAAAAAAAAAAAAAADU3sOUjPhiPbv7W-lBYT4gv8aAgwaXnbjCSJmeWRTz6%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DmmWZBFq6odbyLgounnuPu8js%252FRU%253D)
[C#] 11일차 - 70. 세개의 숫자중 가장 큰 수를 찾는 정적 메소드C#/C#200제2021. 1. 31. 13:29
Table of Contents
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A070_StaticMethods
{
class Methods
{
private int Larger(int x, int y)
{
return (x >= y) ? x : y;
}
private static int Larger2(int x, int y)
{
return (x >= y) ? x : y;
}
static void Main(string[] args)
{
int a = 10, b = 30, c = 20;
Methods x = new Methods(); // Methods 클래스의 객체를 x로 생성합니다.
Console.WriteLine("가장 큰 수는 {0}", x.Larger(x.Larger(a,b),c));
// Larger2는 스태틱으로 선언해 객체 없이 사용가능
Console.WriteLine("가장 큰 수는 {0}", Larger2(Larger2(a, b), c));
}
}
}
반응형
'C# > C#200제' 카테고리의 다른 글
[C#] 11일차 - 72. 윤년인지 알아내는 정적 메소드 (0) | 2021.01.31 |
---|---|
[C#] 11일차 - 71. 소수인지를 알아내는 정적 메소드 (0) | 2021.01.31 |
[C#] 10일차 - 69. 속성(Property) (0) | 2021.01.30 |
[C#] 10일차 - 68. 생성자 메소드 (0) | 2021.01.30 |
[C#] 10일차 - 67. 인스턴스 메소드와 static 메소드 (0) | 2021.01.30 |
@반나무 :: 반나무_뿌리
3년차 WPF 개발자입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!