One of the great string methods that was introduced in dotNet 2.0 is ‘IsNullOrEmpty’
Many times, we need to check data to make sure it’s not an empty string or not null, so 2 tests of the data had to be done. Now, you can use this method to check these for both all at one time.
VB.Net: If [String].IsNullOrEmpty(YourString) = True Then ' do whatever you want here
C#: if (String.IsNullOrEmpty(YourString) == true) // do whatever you want here
Then, you can also include an ‘else’ section to perform an action if the string being tested is NOT empty or is null.
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF
Leave a reply
You must be logged in to post a comment.