일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- mysql
- dotNET
- logging
- log
- coding-test
- Process
- IValueConverter
- algorithm
- programmers
- WPF
- Microsoft
- Coding
- chashtag
- ListView
- tls
- git
- string
- C#
- Visual Studio
- nullable
- csharp
- commit
- Github
- .net
- 코딩테스트
- windows10
- windows
- File
- Binding
- convert
Archives
- Today
- Total
목록C# (73)
CHashtag

아래와 같은 클래스가 있습니다. class Program { internal static List Items = new List(); static void Main(string[] args) { AddDummyValues(); RemoveDummyValues(); } internal static void AddDummyValues() { for(int i = 0; i { Items.Remove(x); }); } } 실행해보면 아래와 같은 예외가 발생합니다. 이는 Remove 뿐만 아니라 Add를 해도 동일한 예외가 발생합..
C#
2020. 10. 26. 01:06

결론부터 알려드리겠습니다. DateTime? dateTime = null; if(dateTime != null) { Console.WriteLine(dateTime.Value.ToString("yyyy")); } 또는 DateTime? dateTime = null; Console.WriteLine(dateTime?.ToString("yyyy")); 을 사용하면 됩니다. 기본적으로 DateTime 형식에는 null이 지원되지 않습니다. 이때 타입 뒤에 "?" 를 붙임으로써 nullable형식으로 만들 수 있는데 이때 DateTime의 ToString함수가 overloading을 제공하지 않습니다. 이때 Nullable의 Value라는 속성을 이용하면 됩니다. 하지만 Value가 null일 경우 System..
C#
2020. 8. 10. 17:36