I have seen questions related to string builder but was not able to find relevant answer.
My question is "Is it wise to use string builder here? if not how to use it wisely here".
This method is going to run 100000 times. In order to save some memory I used stringbuilder here. but the problem is .ToString()
method. Anyway I will have to create a string using .ToString()
method so why not initialize filename
as string rather than StringBuilder
.
internal bool isFileExists()
{
StringBuilder fileName = new StringBuilder(AppDomain.CurrentDomain.BaseDirectory + "Registry\\" + postalCode + ".html");
if (System.IO.File.Exists(fileName.ToString()))
{
return true;
}
else
{
return false;
}
}
All libraries method use string as a parameter not string builder why? I think I got a lot of confusion in my concepts.