-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: ashish4All
Message 4 in Discussion

Hi Anand,   I have done some research on your post (please find the code 
below)....   I find (strA==strB) is faster than strA.Equals(strB) is faster 
than String.Compare(strA, strB)   using System; public class Class2
{
 public static void Main()
 {
        string regString = "This is a Test";
        string testString;
        DateTime startTime;
        DateTime endTime;
        int  counter;
        bool  equal;
  int counter1;   Console.WriteLine("Test compare of Two Strings using = That 
are equal");
        testString = "This is a Test";
        startTime = System.DateTime.Now;
  for (counter = 1; counter <= 10000000; counter++)
  {
   equal = testString==regString? true : false;
  }
        endTime = System.DateTime.Now;
        Console.WriteLine(endTime.Subtract(startTime).TotalSeconds.ToString()); 
  Console.WriteLine("Test compare of Two Strings using String.equals() That are 
equal");
  testString = "This is a Test";
  startTime = System.DateTime.Now;
  for (counter = 1; counter <= 10000000; counter++)
  {
   equal = testString.Equals(regString);
  }
  endTime = System.DateTime.Now;
  Console.WriteLine(endTime.Subtract(startTime).TotalSeconds.ToString());       
  Console.WriteLine("Test compare of Two Strings using String.Compare That are 
equal");
        testString = "This is a Test";
  startTime = System.DateTime.Now;
  for (counter = 1; counter <= 10000000; counter++)
  {
   counter1 = string.Compare(testString, regString);
   //counter1 = testString.CompareTo(regString);
  }
  endTime = System.DateTime.Now;
  Console.WriteLine(endTime.Subtract(startTime).TotalSeconds.ToString());  }
}   Please give your suggestions.   Kind Regards, Ashish

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to