M
MuZZy
Hi,
I'm retouching some utility classes used everywhere across our app, and
there are certain methods used everywhere and pretty frequently. I'm
changing them from instance methods to static ones, so to use them you
don't need to create an instance of that utility class.
So my question is - is there any difference/danger of using a static
method vs instance method.
Example:
//--------- CODE ---------------
class CUtil
{
public string GetColumn(string s)
{
string[] ss = s.Split('.');
if (ss.Length > 1)
return ss[1];
else if (ss.Length > 0)
return ss[0];
else return String.Empty;
}
}
//------ VERSUS: -------------
class CUtil
{
public static string GetColumn(string s)
{
... same implementation ...
}
}
// -------- END OF CODE -------
Any possible memory/performance issues?
Thank you,
MuZZy
I'm retouching some utility classes used everywhere across our app, and
there are certain methods used everywhere and pretty frequently. I'm
changing them from instance methods to static ones, so to use them you
don't need to create an instance of that utility class.
So my question is - is there any difference/danger of using a static
method vs instance method.
Example:
//--------- CODE ---------------
class CUtil
{
public string GetColumn(string s)
{
string[] ss = s.Split('.');
if (ss.Length > 1)
return ss[1];
else if (ss.Length > 0)
return ss[0];
else return String.Empty;
}
}
//------ VERSUS: -------------
class CUtil
{
public static string GetColumn(string s)
{
... same implementation ...
}
}
// -------- END OF CODE -------
Any possible memory/performance issues?
Thank you,
MuZZy