相关疑难解决方法(0)

在.Net中创建对象是否昂贵?

我刚刚重构了一个同事的代码,粗略地看起来像这样......

public class Utility
  public void AddHistoryEntry(int userID, HistoryType Historytype, int companyID)
  {
    // Do something...
  }
  public void AddHistoryEntry(int userID, HistoryType historyType, int companyID, string notes)
  {
    // Do something...
  }
}
Run Code Online (Sandbox Code Playgroud)

对此......

public class HistoryEntry
{
  public long UserID { get; private set; }
  public HistoryType HistoryType { get; private set; }
  public long CompanyID { get; set; }
  public string Notes { get; set; }

  public HistoryEntry(long userID, HistoryType historyType)
  {
    this.UserID = userID;
    this.HistoryType = historyType; …
Run Code Online (Sandbox Code Playgroud)

.net class-design code-design

13
推荐指数
4
解决办法
1076
查看次数

标签 统计

.net ×1

class-design ×1

code-design ×1