Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Strings

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
csharpula csharp - 12 Mar 2008 10:42 GMT
Hello,
What is the best way to compare strings is it str1==str2 or
String.Compare(str1,str2)? Thank you!
Jon Skeet [C# MVP] - 12 Mar 2008 10:56 GMT
> What is the best way to compare strings is it str1==str2 or
> String.Compare(str1,str2)? Thank you!

How about str1==str2?

Note that that will do an ordinal (culture insensitive, case sensitive)
comparison. Your actual requirements may vary from this, in which case
look at the StringComparer class and its various static properties.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Ignacio Machin ( .NET/ C# MVP ) - 12 Mar 2008 12:46 GMT
Hi,

> Hello,
> What is the best way to compare strings is it str1==str2 or
> String.Compare(str1,str2)? Thank you!

In most of the cases you will get the same result.  Any way take a look at
http://blogs.msdn.com/abhinaba/archive/2005/10/28/486173.aspx

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.