Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Compare Two String Using Compare Method in C#
WhatsApp
Mukesh Kumar
Nov 28
2015
1.1
k
0
0
string str1 =
"my string"
;
string str2 =
"This is not my string"
;
if
(String.Compare(str1,str2) < 0)
{
// str1 is less than str2
Console.WriteLine(
"Yes"
);
}
else
if
(String.Compare(str1,str2) == 0)
{
// str1 equals str2
Console.WriteLine(
"Equals"
);
}
else
{
// str11 is greater than str2, and String.Compare returned a value greater than 0
Console.WriteLine(
"No"
);
}
C#
string
Up Next
Compare Two String Using Compare Method in C#