Hello everybody,
What the most commonly over abused methods you came a cross?
For me it woulde be String.Format, I have never seen propper use of that function it always seems to get abused.
One of the worst uses I have ever seen was in an asp.net project:
String.Format(datastring, errorstring);
Where datastring would contain various information from the client concatenated and even the data from some textboxes. datastring would always contain an {0} to which was supposed to get replaced by errorstring.
errorstring was just a general error message.
Now some of you may have already noticed the problem. Because various other strings were pasted together there could contain special symbols cousing the Format method to throw exceptions.
Another bad case of String.Format I came across was:
static void Main(string[] args)
{
string root=args[0];
Directory.GetFiles(String.Format("{0}SomeFolder/Blah", root);
}
root contains a string that got fetched from the command arguments. A good case for Path.Combine.