본문 바로가기

Etc/C#

(9)
MemoryStream + StreamReader ?? class A : IDisposable { public void Dispose() { Console.WriteLine("A Dispose()"); } } class B : IDisposable { public void Dispose() { Console.WriteLine("B Dispose()"); } } using (A a = new A()) { using (B b = new B()) { } } =>이 코드를 Code Analysis을 통해서 Analyze 해보면 "No code analysis issues were detected." 라고 나온다. using (MemoryStream ms = new MemoryStream()) { using (StreamReader reader = new Stream..
What's new in C# 4.0 (Named Arguments) 오웅 오늘 교육 왔는데 교육이 지겨워서 어쩌다가 C#4.0 에서 바뀐 내용을 읽다가 Named Arguments 라는게 있어서 해봤습죵 근데 머 소스의 가독성을 높인다고 하는데 머 그닥... 머 그래도 새로 나왔다니 한번 볼까용? class Program { static void Main(string[] args) { TestMethods(29, "한윤진"); TestMethods(name: "전지현", age: 27); } private static void TestMethods(int age, string name) { Console.WriteLine("나이는 : {0} , 이름은 : {1}", age, name); } } 이런식 으로도 가능 하다는 이야기 이지용 파라미터를 순서에 맞게 넣는게 아니라..
Linq 문에서 Like문 쓰기 http://blog.daum.net/_blog/BlogView.do?blogid=04qAU&articleno=15309449&categoryId=#ajax_history_home 누누히 말하지만 이건 단지 메모일 뿐이영 허허허허허허
Extension Method 사실 Extension Method에 대해서는 작년 초쯤에 공팀장님으로 부터 설명을 들었었는데 그때 듣고 아항~ 하고 넘어 갔더니 지금은 기억이... 금붕금붕 -.,-;;; 그래서 다시 찾아보고 아~ 포스팅(메모) 를 해야 겠구나 싶어서 하는 포스팅(메모)~ -.,-;; class Program { static void Main(string[] args) { string s = "Hello World"; int i = s.WordCount(); Console.WriteLine(i.ToString()); } } //Static Class 여야 하고 public static class baby { //Static Method여야 하고 //parameter 에 this type 을 정해줘야 하는것 같음 -.,..
Func 사용하기 Hoons에서 먼가를 찾다가 발견한 강좌인데 까먹기 전에 포스팅(이라 적고 메모라읽는다)을 하나~ 우선 자세한 내용은 이 강좌를 확인 하시고 여기서는 사용 하는 방법만 메모를 -_-b 좋은 강좌를 써주신 김수영님 캄솨 합니닷~ public MainPage() { InitializeComponent(); int[] source = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; List oddNumbers = FilterOfInts(source, i => ((i & 1) == 1)); List evenNumbers = FilterOfInts(source, i => ((i & 1) == 0)); listbox1.ItemsSource = oddNumbers; listbox2.ItemsSource..
& 과 &&의 차이 // cs_operator_logical_and.cs using System; class MainClass { static bool Method1() { Console.WriteLine("Method1 called"); return false; } static bool Method2() { Console.WriteLine("Method2 called"); return true; } static void Main() { Console.WriteLine("regular AND:"); Console.WriteLine("result is {0}", Method1() & Method2()); Console.WriteLine("short-circuit AND:"); Console.WriteLine("result i..
?? 연산자 에또~ 오늘 코드를 보다가 ?? 연산자를 보았는데요. 처....처음 보는 연산자라서 MSDN을 찾아 보닌까 나와 있더라구용~ 스크립트에서는 ||라고 하는데요 예를들어 int a = b ?? c; 이때 b가 null 이면 c가 들어가고 아니면 b가 들어간다고 하네용~ null체크를 간단하게 할수 있겠네용 :-0
아래 DataBinding 할때 Converter 하는방법!!! 에또~ 아래의 같은 경우에 Enum 타입등의 값들을 Binding 하거나 여러 경우에 원래값을 쵸큼 변경해서 써야 하는 경우가 있을텐데요. 그럴때는 아래와 같이 해주면 된다고 하네용~ Binding binding = new Binding("Text", this, "CurrentEnum"); binding.Format += new ConvertEventHandler(binding_Format); void binding_Format(object sender, ConvertEventArgs e) { MyEnum myEnum = (MyEnum)e.Value; switch (myEnum) { case MyEnum.None: break; case MyEnum.Test1: e.Value = "이건 일번"; break..