Which of the following code segments will you use to accomplish the task?

You work as a Software Developer for ABC Inc. The company has several branches worldwide. The company uses Visual Studio .NET 2005 as its application development platform. You are creating an application using .NET Framework 2.0. The application will be used by all the branches of the company. You are using the CompareInfo class for culture-sensitive string comparisons.

You write the following code in the application:

String s1 = "C rtify";

String s2 = "c rtify";

String s3 = "c rtify";

You need to compare the s1 string with the s2 string and ensure that the string comparison must ignore case.

Which of the following code segments will you use to accomplish the task?
A . CompareInfo cmp = CultureInfo.InvariantCulture.CompareInfo;
Console.WriteLine(cmp.Compare(s1, s2, CompareOptions.IgnoreCase));

B . CompareInfo cmp = CultureInfo.InvariantCulture.CompareInfo;
Console.WriteLine(cmp.Compare(s1, s2, CompareOptions.None));
C . CompareInfo cmp = CultureInfo.InvariantCulture.CompareInfo;
Console.WriteLine(cmp.Compare(s1, s2, CompareOptions.Ordinal));
D . CompareInfo cmp = CultureInfo.InvariantCulture.CompareInfo;
Console.WriteLine(cmp.Compare(s1, s2, CompareOptions.OrdinalIgnoreCase));

Answer: A

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments