Please consider this code:
public static int ToInt (this string str)
{
return Convert.ToInt32 (str);
}
Should I use lock
for this statment?
EDIT 1)
public static int ToInt(this string str)
{
int Id = -1;
if (str.IsEmpty() == true ||
int.TryParse(str.Trim().Replace(",", ""), out Id) == false)
{
throw new Exception("Invalid Parameter: " + str);
}
else
{
return Id;
}
}
is this method thread-sate too?