Pages

RSS

How to Use string.Contains() with switch() in C#

Simple yet efficient with c# 

string sri = "Naveen";
switch (sri) {
     case var s when sri.Contains("ee"):
         Console.WriteLine("oops! worked..."); 
         break;
     case var s when sri.Contains("same"): 
         Console.WriteLine("oops! Not found..."); 
         break; 
 }

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS