전체 글79 Method 메소드는 객체 지향 프로그래밍 언어에서 사용하는 용어로, C언어와 C++ 언어에서는 함수라 불렀고, 파스칼에서는 프로시저라고 불렸습니다. 메소드는 즉 일련의 코드를 하나의 이름 아래 묶은 것입니다. 이렇게 묶은 코드는 메소드의 이름을 불러주는 것만으로 실행할 수 있습니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 using System; namespace Method { class Calculator { public static int Plus(int a, int b) { return a + b; } public static int Minus(int a, int b) { return a - b; } } cl.. 2022. 7. 20. continue 문 컨티뉴 문은 반복문 안에 사용되면 , i가 3인 경우 현재 실행중인 반복을 건너뛰고 다음 반복으로 넘어갑니다. 1234567891011121314151617181920using System; namespace Continue{ class MainApp { static void Main(string[] args) { for(int i = 0; i 2022. 7. 20. break 문 while(true)를 이용하여 무한 루프를 돌면서 사용자로부터 입력을 받다가 "아니오"를 입력받으면 break 문으로 루프를 빠져나와 프로그램을 종료시킵니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 using System; namespace Break { class MainApp { static void Main(string[] args) { while (true) { Console.Write("계속 할까요? (예/아니오) : "); string answwer = Console.ReadLine(); if (answwer == "아니오") break; } } } } Colored by Color Scripter cs 2022. 7. 20. for 또는 while을 이용한 무한 반복 코드2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 using System; namespace InfiniteWhile { class MainApp { static void Main(string[] args) { int i = 0; while (true) Console.WriteLine(i++); } } } Colored by Color Scripter cs while 을 이용한 무한 반복 코드도 역시 같은 결과를 나타내는 것을 알 수 있다. 2022. 7. 20. 이전 1 ··· 5 6 7 8 9 10 11 ··· 20 다음