Q:

Write a C# Sharp program to demonstrate how culture can affect a comparison

0

Write a C# Sharp program to demonstrate how culture can affect a comparison. 

Note : In Czech – Czech Republic culture, "ch" is a single character that is greater than "d". However, in English - United States culture, "ch" consists of two characters, and "c" is less than "d".

Expected Output :

For en-US: change < dollar                                                       
For cs-CZ: change > dollar

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Globalization;
class Example27
{
    public static void Main() {
    String str1 = "change";
    String str2 = "dollar";
    String relation = null;
    relation = symbol( String.Compare(str1, str2, false, new CultureInfo("en-US")) );
    Console.WriteLine("\nFor en-US: {0} {1} {2}", str1, relation, str2);
    relation = symbol( String.Compare(str1, str2, false, new CultureInfo("cs-CZ")) );
    Console.WriteLine("For cs-CZ: {0} {1} {2}\n", str1, relation, str2);
    }
    private static String symbol(int r) {
    String s = "=";
    if      (r < 0) s = "<";
    else if (r > 0) s = ">";
    return s;
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now