The static method is used when developer is really sure the method is only have one instance in the class. There are no other instance that can change that.
eg :
public class People
{
private
public static Int32 GetValue(Int x)
{
return x + 3;
}
}
So even you are make instances of object people, the return from getvalue static method only produce x + 3.
It is usually used when you are really sure to make a functional method like math or physics method.
You can refer to functional programming that using static point of view.
一些旧学校的教gu正在过度使用静态方法,而不是采用OOP方法。
eg:
public class People
{
public static DataSet GetPeopleById(String personId)
{ .... implementation that using SQL query or stored procedure and return dataset ... }
public static DataSet GetXXXXXXX(String name, DateTime datex)
{ .... implementation ... }
}
执行上述措施可达数千条线。
This style happens everywhere to make it like OOP style (because it happen in the class) but thinking like procedural approach.
This is a help since not all people understand OOP style rather than like OOP style.
The other advantage using static are saving memory footprints and faster.
You can see in the blogs : http://www.dotnetperls.com/callvirt