0

Hello Sir,
On Button_click event I have simple code below to compare strings in asp.net

string temp1=Button1.Text;// gives string  "check"
   string temp2="check";  
   if(string.Compare(temp1,temp2)== 0) //but it return  -1
        {
            btnPreview.Text = "complete check";
            
        }

what is wrong with this?
Can anybody help me ..?

Edited by Pari13: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Pari13
0

oh no...
I find the error..
actually problem is in button text:
There is one space before character check.
so it's not "check" but it's " check"
and I'm trying to compare string "check" with " check" .and obviously it will return -1 during comparing..

So Take Care U all .bcz It may be possible that one simple space can change your correct idea.
thanks....

Hello Sir,
On Button_click event I have simple code below to compare strings in asp.net

string temp1=Button1.Text;// gives string  "check"
   string temp2="check";  
   if(string.Compare(temp1,temp2)== 0) //but it return  -1
        {
            btnPreview.Text = "complete check";
            
        }

what is wrong with this?
Can anybody help me ..?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.