Thread: string problem

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    string problem

    Hi:
    is there function that test strings for example:

    string a = "this is a test";
    string b= "test";
    so the function test if b is partially contained in a or exactly the same as a.

    ok:
    I've tried

    String MyString = "Hello World!";
    String OtherString = "Hello!";
    int MyInt = MyString.CompareTo(OtherString);
    Console.WriteLine( MyInt );
    but it returns 1

    if I set OtherString = "Hello My World!";
    it returns 1 too.

    any suggestions?
    thank you
    Last edited by SuperNewbie; 07-19-2002 at 01:36 AM.
    Don't laugh at me,I am just a SuperNewbie.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Try IndexOf instead of Compare.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  4. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  5. Replies: 4
    Last Post: 03-03-2006, 02:11 AM