private class note
{
private int str;
private int frt;
private int beat;
// 아래는 접근자. private로 멤버변수를 만든 후 아래와 같이 변수를 제어한다.
// note1.a_str = 3; 이 처럼 쓰고
// var temp = note1.a_str; 와 같이 가져온다.
public int a_str
{
get { return this.str; }
set { this.str = value; }
}
public int a_frt
{
get { return frt; }
set { frt = value; }
}
public int a_beat
{
get { return beat; }
set { beat = value; }
}
}
문제는 이놈을 클래스로 만들어야 한다는 것.{
private int str;
private int frt;
private int beat;
// 아래는 접근자. private로 멤버변수를 만든 후 아래와 같이 변수를 제어한다.
// note1.a_str = 3; 이 처럼 쓰고
// var temp = note1.a_str; 와 같이 가져온다.
public int a_str
{
get { return this.str; }
set { this.str = value; }
}
public int a_frt
{
get { return frt; }
set { frt = value; }
}
public int a_beat
{
get { return beat; }
set { beat = value; }
}
}
이유는 알 수 없지만
note[] ar_note =
new note[64];
이런 방식으로는 작성할 수가 없었다. 그래서
1.LinkedList로 필요한 만큼의 LinkedList를 만든 후
2.이 LInkedList를 배열로 변환하였다.
2.이 LInkedList를 배열로 변환하였다.
64개 짜리 배열이 5개가 필요했다(guitar1, guitar2, bass, keyboard, drum)
그래서 아래와 같이 만들었다.
LinkedList<note> ll_tmp = new LinkedList<note>(); // 클래스 Note 형태의 LinkedList 선언
note nt_tmp = new note();//임시로 사용할 note 오브젝트 생성
nt_tmp.a_str = 1; // 임시 오브젝트 초기화
nt_tmp.a_frt = -1; // "
nt_tmp.a_beat = -1; // "
// 임시로 만든 오브젝트를 Note형태의 LinkedList에 64번
추가함
for (int i =
0; i < 64; i++){
ll_tmp.AddLast(nt_tmp);
}
//note형태의 클래스 배열 선언
private note[] nt_gt1;private note[] nt_gt2;
private note[] nt_bs;
private note[] nt_kb;
private note[] nt_dr;
// 위에서 만든 LinkedList
"ll_tmp"를 nt_gt1 ~ nt_dr 이라는 note형태의 클래스 배열로 변환,생성
nt_gt1 =
ll_tmp.ToArray();nt_gt2 = ll_tmp.ToArray();
nt_bs = ll_tmp.ToArray();
nt_kb = ll_tmp.ToArray();
nt_dr = ll_tmp.ToArray();
생성 완료.
note[] ar_note =
new note[64];
혹은
note[] ar_note;
ar_note = new note[64];
로 생성했을 때 왜 클래스배열이 생성되지 않는지는..좀 더 공부해봐야겠다.
날림작업으로 코딩하려니 힘들다-0-
혹은
note[] ar_note;
ar_note = new note[64];
로 생성했을 때 왜 클래스배열이 생성되지 않는지는..좀 더 공부해봐야겠다.
날림작업으로 코딩하려니 힘들다-0-
'자기전엔 전기전자 > ZUN장군의 허접 C# 강좌' 카테고리의 다른 글
| C#에서 클래스 변수 생성 시 에러메시지 (--- is inaccessible due to its protection level) (0) | 2010/03/18 |
|---|---|
| C#에서 시리얼통신(how to use serial communication in C#) (3) | 2010/03/06 |
| 다른 폼에서 직렬화(serialize)해서 저장한 파일 열기 (0) | 2010/02/26 |
| C#에서 #define 을 이용한 상수정의 (1) | 2010/02/25 |
| C#, 다른 프로젝트에서 만든 폼 불러오기 (0) | 2010/02/19 |
| can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again. 0 0 (0) | 2010/01/26 |
| C#에서 RSS 불러오기 (0) | 2009/05/27 |
| C# label font size 조절하기 (0) | 2009/05/19 |
| C# 다른 폼(form)의 변수 가져오기 (0) | 2009/05/17 |
| 텍스트박스를 키보드를 이용해 이동시키기 (0) | 2009/05/17 |
| C# 클래스배열 만들기 (0) | 2009/05/17 |


