일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- coding-test
- logging
- Visual Studio
- Github
- windows10
- mysql
- IValueConverter
- Binding
- C#
- .net
- File
- git
- nullable
- string
- Coding
- convert
- csharp
- dotNET
- log
- algorithm
- WPF
- chashtag
- windows
- 코딩테스트
- programmers
- Process
- commit
- tls
- Microsoft
- ListView
Archives
- Today
- Total
CHashtag
[C#] nullable System.InvalidOperationException 해결법 본문
반응형
결론만 알려드리겠습니다.
int defaultValue = 999;
int? nullableInt = null;
// int wrongResult = (int)nullableInt;
// System.InvalidOperationException here
int result = nullableInt.GetValueOrDefault(defaultValue);
// 999
감사합니다.
반응형
'C#' 카테고리의 다른 글
[C#] 요청이 중단되었습니다. ssl/tls 보안 채널을 만들 수 없습니다 해결법 (1) | 2021.02.22 |
---|---|
[C#] get file size (파일 크기 구하는법) (0) | 2021.02.19 |
[C#] OpenFileDialog로 다중 파일 선택, Default Path 지정 (0) | 2021.02.18 |
[C#] 문자열(string) 대문자, 소문자로 변환하기, ToUpperInvariant 란? (0) | 2021.02.17 |
[C#] DateTime to TimeStamp, TimeStamp to DateTime 변환하기 (1) | 2021.02.16 |