Advertisement
jyoung12387

String Comparison - Case Insensitive

Feb 26th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         //string we are comparing
  8.         string quote = "The Broken Blades";
  9.        
  10.         //checking if string starts with "the", case sensitive
  11.         bool startsWithThe = quote.StartsWith("the");
  12.         Console.WriteLine(startsWithThe);
  13.        
  14.         //checking if string starts with "the", case insensitive because of StringComparison.CurrentCultureIgnoreCase
  15.         bool startsWithTheAny = quote.StartsWith("the", StringComparison.CurrentCultureIgnoreCase);
  16.         Console.WriteLine(startsWithTheAny);
  17.        
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement