How to perform case-insensitive two strings comparison in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main()
    {
        string str1 = "Profession: c# Programmer";
        string str2 = "Profession: C# PROGRAMMER";
 
        bool equals = str1.Equals(str2, StringComparison.OrdinalIgnoreCase);
        
        Console.WriteLine(equals);
    }
}


 
/*
run:
 
True
 
*/

 



answered Feb 23, 2025 by avibootz

Related questions

1 answer 110 views
1 answer 114 views
1 answer 108 views
1 answer 115 views
1 answer 95 views
...