본문 바로가기

프로그래밍 언어 노트/C#

(22)
[C#] orderby를 활용한 간단한 셔플 OrderBy(item => random.Next()); linq 로 하면 orderby random.Next() 정도? 각 아이템을 랜덤한 수로 만들어정렬하여 셔플되는것과 같은 효과를 보게한다. 성능은 글쎄.. 간단하게 만들기 좋은듯.
[C#/WPF] XAML을 사용하여 WPF에서 Windows Forms 컨트롤 호스팅 https://docs.microsoft.com/ko-kr/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf-by-using-xaml MSAGL을 WPF 에서띄울려고 사용했다.뭐 서드파티가 대게 winform만 제대로 하고 wpf는 안해주는 경우가 많아서 그때그때 찾다가 포스팅.. 어셈블리 추가 WindowsFormsIntegration System.Windows.Forms 과 같이 WindowsFormsHost 가 가능하다.여기에 x:Name줘서 그냥 사용해도 된다.
[C#/Winform] Microsoft Automatic Graph Layout (MSAGL) https://www.microsoft.com/en-us/research/project/microsoft-automatic-graph-layout/?from=http%3A%2F%2Fresearch.microsoft.com%2Fen-us%2Fprojects%2Fmsagl%2F#!code-samples 뭐 이쁘장하게 그려주는건 아닌데NeGet에서 간단히 다운받고 사용하기 쉽다. Microsoft Automatic Graph Layout using System; using System.Collections.Generic; using System.Windows.Forms; class ViewerSample { public static void Main() { //create a form System.Window..
[Visual Studio] 메서드 자동완성 기능 플러그인 (C# Methods Code Snippets) https://marketplace.visualstudio.com/items?itemName=jsakamoto.CMethodsCodeSnippets 비주얼스튜디오에서 C#은 워낙 킹갓 인텔리센스를 제공해줘서한 두글자쓰고 탭탭 누르면 왠만하면 다 만들어주는데 의외로 메소드에서 이런기능이 없다 해당 플러그인을 깔면 메소드에서도 해당 기능을 지원해준다. method (snippet for instance method) and "method1", "method2", "method3" are taking arguments edition. vmethod (snippet for virtual instance method) and "vmethod1", "vmethod2", "vmethod3" are taking arg..
[C#] 7.0 새로운 기능 out과 함께 초기화 class Program { public static void OutTest(out int arg) { arg = 0; } static void Main(string[] args) { int before; //선언 OutTest(out before); //Out OutTest(out var a); //선언과함께 초기화 가능, Var도 가능 Console.WriteLine(a); } }
[C#] auto property class MyClass{ public int MyField { get; set; }}getter setter를 줄여주는 C#의 킹갓 기능property 와 그마저도 줄여주는 auto-property. get;만쓰면 setter는 없고set만 쓰면 getter는 없고getter과 setter를 좀더 자세하게 구현하고싶으면 저기다가 구현하면된다. 여기서 그냥 get;set;만 쓰는경우대체 public과 무엇이 다른가! 내부적으로 다르다고 한다.그런데 내부적으로 다른게 대체 뭐가 중요한지 결국 public과 똑같이 작동하고똑같이 사용하는데 그냥 public과 대체 무엇이 다른건가 궁금해서 찾아 보았다. 간단히 설명하자면 auto-property가 존재한다는것은 내가 MyClass.MyField를 했을때 이게..