Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] C# Bool Variable always false

Status
Not open for further replies.

rkt_167

Junior Member level 1
Joined
Aug 9, 2013
Messages
19
Helped
3
Reputation
6
Reaction score
3
Trophy points
3
Activity points
163
hi all,

I am comparing two strings:

Code C# - [expand]
1
bool d = (String.Equals(ethernetHeader.Source,staticForm.textBox1.Text.ToString()));



this statement is always false even in console both are same as below..
ethernetHeader.Source=00:25:64:4F:21:D9
textBox1.Text=00:25:64:4F:21:D9

any possible reason??

thanks,
 

should work - could you have spaces or a newline in one of the strings? try printing the strings e.g.
Code:
            Console.WriteLine(" '{0}' '{1}' {2}\n", ethernetHeader.Source, staticForm.textBox1.Text.ToString(), d);
you should then see if the strings are identical

also you don't require the ToSting() in staticForm.textBox1.Text.ToString()
staticForm.textBox1.Text returns a string
 
thanks horace1,
Code:
bool d = (String.Equals(ethernetHeader.Source.ToString(), staticForm.textBox1.Text.Trim()));

I used Trim() and now it is working fine.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top