You must Sign In to post a response.
  • Category: .NET

    String compare logic needed

    hi All, i need to compare the string of like this "

    System Bundle (Linux)DL2100 v512 vs System Bundle (Linux)DL2100 v560

    except v512 and v560 are different. but rest of things are same.. so in if condition it has to be true

    so please help in this case
  • #763225
    Hi,

    protected void Btn_Submit_Click(object sender, EventArgs e)
    {
    string Firststring = TextBox1.Text;
    string Secondstring = TextBox2.Text;
    try
    {

    if (Firststring == Secondstring)
    {
    TextBox3.Text = "Both are Equal";
    }

    else
    {
    TextBox3.Text = "Both Not Equal";
    }

    }
    catch(Exception ex)
    {
    ex.Message.ToString();

    }
    }
    }


    Hope this will help

    Regards
    Sriram.R

  • #763303
    Hello,

    Please try with the below code :-

    string strA = ""; //provide string value
    string strB = ""; //provide string value

    int flag = strA.CompareTo(strB);


    if (flag==0){
    Console.Writeline("String Matches");
    }
    else {
    Console.Writeline("String does not match");
    }

    Hopefully, above code will help you,



    Thanks


Sign In to post your comments