본문 바로가기
C#

C# string null, 공백 체크

by 따봉이 2021. 12. 13.
728x90
반응형

 public static bool IsValidId(string name)
        {
            return (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name)) ? false : true;
        }

 

 

string.IsNullOrEmpty : 지정된 문자열이 null이거나 빈문자열""인지 확인

string.IsNullOrWhiteSpace : 지정된 문자열이 null이거나 공백문자로만 구성되어 있는지 확인

 

 

 

728x90
반응형

댓글