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

결론부터 알려드리겠습니다. 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