Resharper喜欢指出每个asp.net页面可以静态化的多个函数.如果我让它们静止,对我有帮助吗?我应该将它们设置为静态并将它们移动到实用程序类吗?
假设我有一堂课
public class product
{
public string GetName()
{
return "product";
}
public static string GetStaticName()
{
return "product";
}
}
Run Code Online (Sandbox Code Playgroud)
这些方法做同样的事情,但一个是静态的,一个不是.
当我调用这些方法时,我这样做:
product p = new product();
string _ProductName = p.GetName();
Run Code Online (Sandbox Code Playgroud)
和
string _ProductName = product.GetStaticName();
Run Code Online (Sandbox Code Playgroud)
哪种方法最适合用于性能等?