| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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
                            
                        
                          
                          - Coding
- git
- 코딩테스트
- nullable
- IValueConverter
- windows10
- csharp
- File
- chashtag
- Process
- C#
- mysql
- algorithm
- logging
- dotNET
- WPF
- convert
- Microsoft
- windows
- .net
- commit
- Visual Studio
- Binding
- coding-test
- programmers
- ListView
- tls
- string
- log
- Github
                            Archives
                            
                        
                          
                          - Today
- Total
목록nullable (2)
CHashtag
 [C#] nullable System.InvalidOperationException 해결법
      
      
        [C#] nullable System.InvalidOperationException 해결법
        결론만 알려드리겠습니다. int defaultValue = 999; int? nullableInt = null; // int wrongResult = (int)nullableInt; // System.InvalidOperationException here int result = nullableInt.GetValueOrDefault(defaultValue); // 999 감사합니다.
        C#
        
        2021. 2. 18. 00:50
      
     [C#] DateTime nullable 에서의 ToString("yyyy-MM-dd") ?(System.InvalidOperationException)
      
      
        [C#] DateTime nullable 에서의 ToString("yyyy-MM-dd") ?(System.InvalidOperationException)
        결론부터 알려드리겠습니다. 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