I'm trying to optimize a few methods while I'm converting the code from VB.net ( version 1.1 ) to c# ( version 2.0 )
I found a lot of these statements to compare strings :
I have chosen to rewrite them as simply :Code:If String.Compare(e.CommandName, "viewcollection", True) = 0 Then
is either way any more efficient than the other?Code:if(e.CommandName.ToLower() == "viewcollection")
Normally, this wouldn't be such a big deal but I found hundreds of these statements and want to minimize overhead as much as possible.
Statement 1 uses a static(shared) method of the string class and statement 2 simply does a comprison. Does statement 2 create a copy of the string and therefore creates more overhead?




Reply With Quote