일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- string
- log
- Coding
- dotNET
- algorithm
- nullable
- chashtag
- Binding
- logging
- IValueConverter
- windows10
- coding-test
- git
- 코딩테스트
- .net
- C#
- ListView
- csharp
- Github
- Microsoft
- tls
- programmers
- Visual Studio
- commit
- File
- WPF
- Process
- windows
- mysql
- convert
Archives
- Today
- Total
목록extension method (1)
CHashtag
[C#] Extension Method 요청인자가 null일 때 NullReferenceException이 발생하지 않는 이유
아래 코드를 보다 불현듯 이런 생각이 스쳤다. public static class Extensions { public static string TestExtension(this string value) { return value + "Hi"; } } public class Program { public void Main(string[] args) { string a = null; var b = a.TestExtension(); } } 보통 null에 대한 method를 호출할 때 NullReferenceException(이하 NRE)이 발생하지 않나? 라는 생각이. 그러나 Extension Method에서는 NRE가 발생하지 않는다! 그 이유는, Extension Method가 il코드로 변환될 때 ca..
C#
2023. 1. 17. 22:07