I recently reorganized some code and now have a static utility class with this way:
const int x = 1;
public static string doWork(ref DataTable dt)
{
decimal total = 0;
foreach (DataRow row in dt.Select("COST_ID = " + x))
{
decimal annual = decimal.Parse(row["Cost"].ToString());
total += decimal.Round(annual, 2);
}
return String.Format("{0:C}", total);
}
I simplified the example for clarity ...
Perhaps I experienced any negative consequences of this and placing the doWork method call in the code behind the ASP.NET application that affects many users? Does anyone know or have a link where I can read how, in terms of performance, the static method will work? Is it becoming a bottleneck of any kind?
EDIT:
Yes, I apologize, it was not a very good example, so let's say something else like this:
const int x = 1;
public static string doWork(ref DataTable dt)
{
foreach (DataRow row in dt.Select("COST_ID = " + x))
{
row["Cost"] = 0.0;
}
}
You say that A) I donβt even need a link here, since Datatable is already passed ref and B). Performance is not at all hit by βforwardingβ all calls to one static method.