I was looking through some source code for a class I was using, and found the following block of code:
if (provider.Equals("LOADEXTPROVIDER"))
{
OutputLine(" Assembly: " +
providerAssembly);
OutputLine(" Connection Class: " +
providerConnectionClass);
}
Now, the .Equals method has several overloads that take care of a variety of other potential tasks, but can anyone tell me why you would want to use this method for a textual comparison? Why not simply:
if(provider == "LOADEXTPROVIDER")
Are we just trying to accomodate varying coding styles, since we’re creating the method for other purposes as well? Is there actually a language out there that doesn’t support == (or simply = in farked up languages like Delphi)?
1. your blog does not remember the name email and website I entered in my previous comment.
2. I would guess this is C# and not Java.
I dont know C#, but in Java there a good reason to do it, which has to do with comparing the references versus comparing the actual string.
however, if there is no need for it in C# (Operator overloading?), I would further guess that this was written by a Java programmer.