728x90
반응형
1. 핵심 정리
using System;
class Program {
public static void Main() {
// int n1;
// Console.WriteLine(n1); - error
int n1 = 10;
Console.WriteLine(n1);
// double n2 = 10;
// int n3 = n2;
double n2 = 10;
var n3 = n2;
}
}
① 초기화 되지 않은 변수는 사용(Read)할 수 없다.
② var (C++의 auto)
=> 우변의 타입에 따라 좌변의 타입이 결정
=> 프로그래밍을 하며 데이터 타입이 바뀔 때 유용
2. 추가 특징
using System;
class Program {
public static void Main() {
10.ToString();
int n = 10; // System.Int32
string s1 = "AAA";
String s2 = "AAA";
System.String s3 = "AAA";
System.Int32 n2 = 10;
Int32 n3 = 10;
}
}
① C#에서 모든 것은 객체이다.
=> 10, 3.4, "AAA"도 모두 객체이다. (멤버를 가지고 있다.)
② C#의 타입과 .net framework
728x90
반응형
'프로그래밍 > C#' 카테고리의 다른 글
[C#] 값 타입과 참조 타입(1) (1) | 2020.01.22 |
---|---|
[C#] System.Object (0) | 2020.01.21 |
[C#] 인터페이스 (interface) (1) | 2020.01.17 |
[C#] 클래스 기본 문법 (1) | 2020.01.13 |
[C#] 표준 입력 (0) | 2020.01.13 |