투케이2K

106. (C#/NET) [Mac Os] [문법] Random 사용해 랜덤 정수 값 출력 수행 본문

C샵 (NET)

106. (C#/NET) [Mac Os] [문법] Random 사용해 랜덤 정수 값 출력 수행

투케이2K 2024. 3. 20. 21:06
반응형

[개발 환경 설정]

개발 언어 : C# / NET

 

[소스 코드]

using System;
using System.Collections;
using System.Data;
using System.Diagnostics.Tracing;
using System.Text;
using System.Text.Json.Serialization;
using System.Web;
using System.Text.Json;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.Text.RegularExpressions;

namespace testProject {

    // [프로그램 동작 클래스]
    class Program {

        // [메소드 수행]
        static void Main(string[] args){

            // [Random 선언]
            Random rand = new Random();


            // [for 문 사용해 랜덤 정수 출력]
            for (int i=0; i<3; i++){
                
                int value = rand.Next(1, 10); // [1 ~ 10 범위]

                Console.WriteLine($"value : {value}");
            }

        }

    }

}
 

[결과 출력]

 

 
반응형
Comments