본문 바로가기

IT Study/C#12

[C#] Stopwatch를 사용하여 작업 속도 측정 업무 중에 속도 개선해야 할 일이 있어서 측정을 위해 테스트 코드로 작성해봤다. using System.Diagnostics; Stopwatch sw = new Stopwatch(); sw.Start(); // Do Something sw.Stop(); Console.Write(sw.ElapsedMilliseconds.ToString() + "ms"); 2021. 11. 22.
[C#][.Net WinForm][오류해결] the designer could not be shown for this file because none of the classes within it can be designed 윈폼 개발중에 아래의 오류를 겪었는데 이 문제를 해결하기 위해 검색했다. 프로젝트 속성 > Build > Platform Target이 x64에서 Any CPU로 변경했더니 정상적으로 Design Mode 진입이 되었다. https://stackoverflow.com/questions/6683255/the-designer-could-not-be-shown-for-this-file-because-none-of-the-classes-within The designer could not be shown for this file because none of the classes within it can be designed We have the following shared component: public cl.. 2021. 11. 19.
[C#][.Net WinForm] DateTimePicker 디버그 중 프로그램 응답 없음 VS2010에서 WinForm 프로그램 개발중 DateTimePicker의 ValueChanged 이벤트에 중단점을 걸었는데.. Hit하면 VS와 WinFormApp 둘 다 응답없음이 뜨는 이슈를 겪었다. https://developercommunity.visualstudio.com/t/debugger-crashes-on-datetimechanged-event/218801 Debugger crashes on DateTimeChanged event The strange thing is that VS crashes/becomes unresponsive before you can do anything in the debugger. So VS stops at the breakpoint and waits for .. 2021. 6. 2.
[C#] Null이 아니라 EventArgs.Empty를 사용하는 이유? 코드를 쓰면서 밑의 두 가지 모두의 코드를 많이 접했는데 sender object와 event argument가 필요 없는 상황에서 이벤트 처리 메서드를 일반적으로 사용할 때 어떤 Param을 넘겨야 하고 어떤 차이가 있는걸까? protected virtual OnSomethingHappened() { this.SomethingHappened(this, EventArgs.Empty); } protected virtual OnSomethingHappened() { this.SomethingHappened(null, null); } 그에 대한 답은 스택 오버플로우에 정리 되어있었다. Null을 전달하고 e로 무언가를 시도했을 때 발생하는 잠재적인 Null 참조 예외를 피하기 위함. https://stacko.. 2021. 5. 27.
[C#] XML Convert to CSV XmlDocument 클래스 사용해서 Xml Parsing을 해보자. 아래의 Xml 문서는 w3school에 예제로 있는 자료인데 직접 만들기 귀찮으니 활용했다. Belgian Waffles $5.95 Two of our famous Belgian Waffles with plenty of real maple syrup 650 Strawberry Belgian Waffles $7.95 Light Belgian waffles covered with strawberries and whipped cream 900 Berry-Berry Belgian Waffles $8.95 Belgian waffles covered with assorted fresh berries and whipped cream 900 Fren.. 2021. 3. 13.
[C#] MDI (Multiple Document Interface) MDI : SDI와는 달리 폼 안에 여러 Child Form을 가지는 형태. - C# 에서는 MdiParent를 통해 Parent Form과 Child Form을 연결하는 메서드를 지원한다. MDI 자식 양식 정렬 - LayoutMdi 메서드의 인수로 MdiLayout 열거형 값을 사용하여 MDI 부모 폼에서 자식 폼을 정렬할 수 있다. - 계단식 정렬 (MdiLayout.Cascade) - 수평 정렬 (MdiLayout.TileHorizontal) - 수직 정렬 (MdiLayout.TileVertical) 코드 - Form1.cs (MDI 부모 폼) using System; using System.Collections.Generic; using System.ComponentModel; using Sys.. 2021. 3. 13.