아래는 3차원 Array 선언 방법을 보여주는 샘플 코드입니다. 조금 헷갈릴 수 있는데, 잘 살펴보시기 바랍니다. namespace ArraySample { class Program { static void Main(string[] args) { // An example of a three-dimensional array: int[, ,] array3D = new int[2, 3, 2] { { { 1, 2 }, { 1, 2 }, { 1, 2 } }, { { 1, 2 }, { 1, 2 }, { 1, 2 } } }; } } }
Array 선언 방법과 마찬가지로 Multidimensional Array 선언 방법도 몇가지가 있습니다. 아래는 Multidimensional Array 선언 방법을 보여주는 샘플 코드입니다. namespace ArraySample { class Program { static void Main(string[] args) { // Multidimensional Array int[,] array1; array1 = new int[2, 3]; int[,] array2 = new int[2, 3]; int[,] array3 = new int[2, 3] { { 1, 2, 3 }, { 4, 5, 6 } }; int[,] array4 = new int[,] { { 1, 2, 3 }, { 4, 5, 6 } }; in..
C#에서 array를 선언하는 방법은 몇가지가 있습니다. 아래는 int array를 선언하는 방법을 보여주는 샘플 코드입니다. namespace ArraySample { class Program { static void Main(string[] args) { // Array int[] aArray; aArray = new int[10]; int[] bArray = new int[5]; int[] cArray = new int[3] { 1, 2, 3 }; int[] dArray = new int[] { 1, 2, 3, 4, 5 }; int[] eArray = { 1, 2, 3, 4, 5 }; } } }
아래는 Random 예제이다. i 값이 20부터 1까지 하나씩 줄어든다. 이때, i 값 보다 작은 임의의 정수를 출력하는 예제이다. using System; namespace RandomSample { class Program { static void Main(string[] args) { Random myRandom = new Random(); for (int i = 20; i > 0; i--) { Console.WriteLine(myRandom.Next(i)); } } } }
아래는 Event에 Anonymous method를 추가하는 간단한 예제 코드이다. using System; namespace EventSample { public delegate void Conduct(); class Program { public static event Conduct myEvent; static void Main(string[] args) { myEvent += delegate() { Console.WriteLine("Hi"); }; myEvent += delegate() { Console.WriteLine("Ho"); }; myEvent(); } } }
아래는 Anonymous method를 Adapter로 이용한 간단한 예제이다. using System; namespace DelegateSample2 { delegate void Action(); class Program { static void Main(string[] args) { myAction += delegate() { Console.WriteLine("1st"); }; myAction += delegate() { Console.WriteLine("2nd"); }; myAction(); } public static Action myAction; } }
Delegate & Event 예제 간단한 Delegate & Event 예제 입니다. 아래에서 주의 할 점은 public event 를 부를 수 있는 것은 그 event 가 속해있는 class의 method 뿐이라는 것입니다. Anonymous Method 의 사용법도 눈여겨보시기 바랍니다. Anonymous Method 를 사용할 때, close brace " } " 다음에 세미콜론 " ; " 을 붙여야합니다. using System; namespace DelegateSample { class Program { static void Main(string[] args) { Human Tom = new Human(); Tom.ActionDelegate += new Action(Tom.Speak); Tom..
- Total
- Today
- Yesterday
- Microsoft
- 유틸리티
- READYSTATE_COMPLETE
- AdSense감추기
- registry
- download.com
- AxWebBrowser
- DotNetMagic
- jre
- java
- WinAutomation
- windows
- 애드센스숨기기
- Service pack
- Sample Code
- Phalanger
- 스크린캡쳐
- .net framework
- Rollback Rx
- Automation
- ScreenHunter
- iTextSharp
- iText
- autohotkey
- c#
- 애드센스감추기
- tagREADYSTATE
- AdSense숨기기
- Regular Expressions
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |