String Name;
While(Name== "Himanshu" || "HIMANSHU" )
{
//Both the names above are same but have Different because Capital and Small letters.
}

what to do in this ??

Recommended Answers

All 3 Replies

there is no need for OR operator.... use this

while(name.toUpper().equals("anything".toUpper()))
{
    //-------- use to upper function to make it in one case and equal to compare them.
    // Above is java syntax i hope there will be same in c#
} 

you can do

while (!Name.Equals("himanshu", StringComparison.OrdinalIgnoreCase))
{
    // do something
}

That will compare your string variable to a string and ignore the case of the strings. Here's a link to Microsoft's "Best Practices for Using Strings"

string name;
while (name == "Himanshu" || name == "HIMANSHU") //while should begin with a small 'w'
    {
        //Code
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.