분류 전체보기
-
델리게이트프로그래밍 언어/클래스 2011. 7. 28. 16:36
*델리게이트 객체 -> System.Delegate함수 포인터메소드의 형태에 따라 델리게이트를 정의 c.f. 인터페이스 using System; delegate void SampleDelegate(); class DelegateClass { public void DelegateMethod() { .. } } class DelegateApp { public static void Main() { DelegateClass obj = new DelegateClass(); SampleDelegate sd = new SampleDelegate(obj.DelegateMethod); // or SampleDelegate sd = obj.DelegateMethod; sd(); // invoke obj.DelegateMe..
-
연산자 오버로딩(중복 선언) - C#프로그래밍 언어/클래스 2011. 7. 28. 16:29
class Even { int evenNumber; public Even(int n) { evenNumber = (n % 2 == 0) ? n : n + 1; } public static Even operator ++(Even e) { e.evenNumber += 2; return e; } public static Even operator --(Even e) { e.evenNumber -= 2; return e; } } class Complex{ private double realPart; private double imagePart; public Complex(double rVal, double iVal) { realPart = rVal; imagePart = iVal; } public static C..
-
C#프로그래밍 언어/클래스 2011. 7. 28. 00:42
*클래스 public 상속만 지원하며 다중 상속을 지원하지 않는다클래스와 인터페이스로부터 다중 상속받을 때는 항상 클래스가 선언문의 제일 앞에 와야 한다.인터페이스로부터 상속된 같은 이름을 가지는 메서드들은 클래스에서 한 번만 구현하면 된다비가상 메서드는 정적 타입을 따른다 .ToString() // virtual * 인터페이스메서드, 프로퍼티, 인덱서, 이벤트만 멤버가 될 수 있다 IDisposableusing 블록에서 자동으로 호출된다 void Dispose(); ICloneableobject Clone(); *partial class Human { // C# 2.0public int Age;public string Name;} partial class Human {public void Intro()..
-
C#Data/string 2011. 7. 27. 22:46
System.String or string.Parse() // static .==().+().Format() // static object.ToString() string s = ".."; or string s = new string(".."); string str1;str1 = ".."; System.Text.RegularExpressions.Match.Index.ValueSystem.Text.RegularExpressions.MatchCollectionSystem.Text.RegularExpressions.Regex.Matches() // staticusing System;using System.Text.RegularExpressions;class CSTest{static void Main() {st..
-
배열 - C#Data/Container 2011. 7. 27. 22:43
배열의 원소는 0값으로 초기화가 이루어진다위치가 아닌 배열 자체의 상등 여부를 평가하고 싶다면 배열 요소들이 같은지를 직접 비교해야 한다c.f. 문자열 Array.Sort() // static.Reverse() // static .[]().Length int[] initArray = {0, 1, 2, 3, 4, 5}/*or int[] initArray;initArray = new int[] {0, 1, 2, 3, 4, 5};*/Unit[] arUnit = { new Marine(), new Tank(), new Zealot() };foreach (int a in initArray) {..} string[] args; int[,] ar2 = { { 1, 2 }, { 3, 4 }, { 5, 6 } };int..
-
윈도우 - C#GUI/Window 2011. 7. 27. 19:33
System.ComponentModel.Component -> System.MarshalByRefObject.Dispose() System.Windows.Forms.Control -> System.ComponentModel.Componenton Paint // PaintEventHandler .Width.Height.IsDisposed .Show().Invalidate() System.Windows.Forms.ScrollableControl -> System.Windows.Forms.Control.AutoScrollPosition System.Windows.Forms.ContainerControl -> System.Windows.Forms.ScrollableControl.BindingContext[] S..
-
C#스트림 IO/텍스트 프로세싱 2011. 7. 26. 00:37
System.Console // static? .WriteLine() // static.Write() // static .ReadLine() // static .Read() // static static int ReadInt() { char ch; int n = 0; while (!char.IsDigit(ch = (char)Console.Read())) ; do { n = n * 10 + (ch - '0'); ch = (char)Console.Read(); } while (char.IsDigit(ch)); return n; } System.IFormattablestring ToString(string format, IFormatProvider formatProvider);using System;class..
-
JavaScript프로그래밍 언어/제어 구조 2011. 7. 25. 21:18
if (hour > 4 && hour < 19) { .. } else { .. } switch (name) { case "Adam":...break; case "Jacqui":...break; default:...break;} function devide(x, y){if (y == 0) {var err = new Error("Can't devide by zero.");throw err;}return x/y;}try {var b = devide(10, 0);} catch(e) {console.log(e);}