개발 노트

C# 책 포스팅 본문

프로그래밍/C#

C# 책 포스팅

알 수 없는 사용자 2022. 3. 16. 10:50

[3장] 문자열보간 109 - 111

https://capri.tistory.com/257

 

[6장] 메소드로 코드 단축

클래스 선언

	class Calculator
		{
			public static int Plus(int a, int b)
			{
				Console.WriteLine("Input : {0},{1}", a, b);

				int result = a + b;
				return result;
			}
		}

폼로드시 Plus메소드 사용

	private void Form1_Load(object sender, EventArgs e)
		{
		 int x =	Calculator.Plus(1, 2);
		 int y =	Calculator.Plus(3, 2);
		 int z =	Calculator.Plus(3, 1);
			MessageBox.Show(x.ToString());
			MessageBox.Show(y.ToString());
			MessageBox.Show(z.ToString());
		}

 

188페이지

Calculator 안에 Plus Minus 메소드를 만들고 결과를 return 반환하게한다

폼 로드할때 result를 선언해서 만든 메소드에 인자를 넣어 콘솔로그에 result값을 보여준다

 

190페이지