Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
MonthlyLeaders
ASK A QUESTION
Forumguidelines
harish reddy
1.8k
162
17.2k
String compare result
Jan 22 2018 11:05 PM
string str1 = "COMPUTER";
string str2 = "computer";
string str;
int result;
Console.WriteLine();
Console.WriteLine("str1 = '{0}', str2 = '{1}'", str1, str2);
Console.WriteLine("Ignore case:");
result = string.Compare(str1, 2, str2, 2, 2, true);
str = ((result < 0) ? "less than" : ((result > 0) ? "greater than" : "equal to"));
Console.Write("Substring '{0}' in '{1}' is ", str1.Substring(2, 2), str1);
Console.Write("{0} ", str);
Console.WriteLine("substring '{0}' in '{1}'.", str2.Substring(2, 2), str2);
in above example, in this line result = string.Compare(str1, 2, str2, 2, 2, true);
why "true" is there? Also when i complie i am getting result as 0, result=0;
pls let me know.
Reply
Answers (
3
)
Refactoring exercise- Improvements to the below code snippet
How to get the value of selected checkbox in controller?