Advertisement
karlakmkj

String - null or empty

Nov 26th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace StringTheException
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.      Console.Write("Please enter a number or word.");
  10.      string msg = Console.ReadLine();
  11.  
  12.      if (msg == null || String.IsNullOrEmpty(msg) ){    //to check if string is null or empty
  13.        Console.WriteLine("You didn't enter anything!");
  14.      }
  15.      else{
  16.        Console.WriteLine("Thank you for your submission!");
  17.      }
  18.  
  19.     }
  20.   }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement