번역/C# Notes for Professionals
11.5: String.IsNullOrEmpty() 와 String.IsNullOrWhiteSpace() 를 이용하여 빈 문자열 여부를 확인하기
노초코
2021. 1. 28. 22:38
Section 11.5: String.IsNullOrEmpty() 와 String.IsNullOrWhiteSpace() 를 이용하여 빈 문자열 여부를 확인하기
string nullString = null;
string emptyString = "";
string whitespaceString = " ";
string tabString = "\t";
string newlineString = "\n";
string nonEmptyString = "abc123";
bool result;
result = String.IsNullOrEmpty(nullString); // true
result = String.IsNullOrEmpty(emptyString); // true
result = String.IsNullOrEmpty(whitespaceString); // false
result = String.IsNullOrEmpty(tabString); // false
result = String.IsNullOrEmpty(newlineString); // false
result = String.IsNullOrEmpty(nonEmptyString); // false
result = String.IsNullOrWhiteSpace(nullString); // true
result = String.IsNullOrWhiteSpace(emptyString); // true
result = String.IsNullOrWhiteSpace(tabString); // true
result = String.IsNullOrWhiteSpace(newlineString); // true
result = String.IsNullOrWhiteSpace(whitespaceString); // true
result = String.IsNullOrWhiteSpace(nonEmptyString); // false
본 문서는 C# Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요.
[출처] https://books.goalkicker.com/CSharpBook/
반응형