Lee Saerom

C# 내가 적은 (입력한 값)을 받는 방법 본문

C#

C# 내가 적은 (입력한 값)을 받는 방법

Lee Saerom 2022. 10. 31. 18:53

예)

using System;
class HelloWorld {
static void Main() {
    


    int a;
    string ab;
    
    Console.Write("원하는 내용을 입력하세요 : ");
    ab = Console.ReadLine();  // 그냥 입력을 받으면 string으로 입력이 받게 됩니다.
    a = Convert.ToInt32(ab);  // ad를 a 값에 넣는 과정입니다 (참고:a는 int입니다)
    for (int count=0 ; count <a ; count++) {   //만약 a가 count보다 더 크다면count증가시켜라 라는 뜻입니다

    //그러면 이제 나올 수 있는 것은 5를 적으면 5가 되겠죠?
        Console.WriteLine("딸기");
    }
  }
}