목표: C#에서 사용하고자 하는 데이터를 class type(Struct)로 만들어 보자.
* 주의점: Main Form보다 상위에 Class를 선언하면, UI error가 발생함.
==============================================================================
구조체는 Value타입이고 Class는 Reference타입니다.
으잉? 항상 듣는 소리다. ‘Value와 Reference’
차이점은 이거면 충분히 알 수 있다.
int a = 10;
int b = a;
a = 20;
현재 b의 값은? 당연히 10이다. Value타입이니까
class ClassA
{
public int valTest = 0;
}
ClassA a = new ClassA();
ClassA b = a;
a.valTest = 5;
현재 b.valTest의 값은? 당연히 5다. b는 new ClassA();에서 생성된 메모리 번지를 가리키고 있기 때문이다. Reference니까
그럼
struct StructA
{}
StructA a = new Struct();
StructA b = a;
이건?
다시말하지만 struct는 Value타입이다 기억해두도록
[출처] struct와 class의 차이점|작성자 김플레
==============================================================================
// This structure create the DataBase which the variables used in the this program.
public class PKGDataStructure
{
public PKGDataStructure() { }
~PKGDataStructure() { }
// TestInfo
// Summary View
public string strFilePath;
};
'프로그래밍 > .Net' 카테고리의 다른 글
외부응용프로그램 실행하기(Process.Start 메서드) (0) | 2014.01.17 |
---|---|
Ping Test를 해보자 (0) | 2014.01.17 |
To execut the another Form(form dialog를 띄워보자) (0) | 2014.01.17 |
file access, file을 생성하고 읽어보자 (0) | 2014.01.17 |
OpenFileDialog 사용하기.(OpenFileDlg) (0) | 2014.01.17 |