Skip to content

Strings and Characters Program

Steph Bassos

Asked Aug 7, 2013, 8:22 PM EDTSolved
Share
LinkedInX
Write an application that uses string method CompareTo to compare two strings input by the user. Output whether the first string is less than, equal to or greater than the second.

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • ✓ Accepted answer0
    Source code attached.
    0
  • 0
    Hope the below code helps you.

                  string string1 = textBox1.Text;             
                 string string2=textBox2.Text;
                 var result = string1.CompareTo(string2);
                 
                 if (result == -1)
                     MessageBox.Show("Input 2 is bigger");
                 else if (result == 0)
                    MessageBox.Show("Both Input 1 & Input 2 are equal");
                 else 
                     MessageBox.Show("Input 1 is bigger");
    0
  • 0
    How do I set that up in VS to run it?
    0
  • Sunny  Sharma
    0
    Steph,

    Very like I replied on your previous question, please don't assign your homework to the forum. Be specific with the problem stopping you from going ahead and share your code as it could be worthy getting help more than sooner.
    0