언어/C#

null 과 빈 값 체크 : IsNullOrEmpty

앨리스.W 2022. 6. 29. 08:21

✏️string 변수의 널값과 빈값 체크

string stext = "abc";
if(stext == null || stext ="")
{
}

이렇게 따로 쓸 수 있지만 더 간단한 방법이 존재한다.

 

📌IsNullOrEmpty를 이용

if(string.IsNullOrEmpty(stext)==true)
{
}

 

 

반응형