본문 바로가기

C#

C# 변수와 메모리

반응형

값 형식

  • 스택 메모리에 저장
  • 데이터 형식: bool, char, byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal, enum
int i = 1;
short s = 2;
byte b = 3;
주소 메모리 변수이름
504 1 i
505
506
507
주소 메모리 변수이름
502 2 s
503
주소 메모리 변수이름
501 3 b

 

 

 

 

 

 

 

 

 

 


참조 형식

  • 힙 메모리에 저장
  • 데이터 형식: string, class, interface, delegate, object
string str = "hi";

 

반응형