투케이2K

109. (C#/NET) [Mac Os] [문법] GetType 사용해 변수로 선언된 데이터 타입 확인 실시 본문

C샵 (NET)

109. (C#/NET) [Mac Os] [문법] GetType 사용해 변수로 선언된 데이터 타입 확인 실시

투케이2K 2024. 3. 24. 08:55
반응형

[개발 환경 설정]

개발 언어 : 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){

            // [변수 선언]
            string str_Type = "hello Twok";
            int int_Type = 10;
            bool bool_Type = true;


            // [로그 출력]
            Console.WriteLine($"");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"[Main] : [Log]");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"str_Type : {str_Type.GetType().Name}");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"int_Type : {int_Type.GetType().Name}");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"bool_Type : {bool_Type.GetType().Name}");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"");

        }

    }

}
 

[결과 출력]

 

 

반응형
Comments