假设我们有一个带有很多冗余访问器的生成类。它们只是访问器,它们不是字段。他们在任何地方都没有被调用。他们只是坐在那里多余和丑陋。
例如:
public class ContrivedExample
{
public int ThisOneIsUsed { get; set; }
public int ThisOneIsNeverCalled0 { get { /* Large amounts of logic go here, but is never called. */ } }
public int ThisOneIsNeverCalled1 { get { /* Large amounts of logic go here, but is never called. */ } }
public int ThisOneIsNeverCalled2 { get { /* Large amounts of logic go here, but is never called. */ } }
//...
public int ThisOneIsNeverCalled99 { get { /* Large amounts of logic go here, but is never called.*/ } }
}
ContrivedExample c = new ContrivedExample() { ThisOneIsUsed = 5; }
我能想到的唯一开销是它会使 .DLL 更大。我希望运行时惩罚为零。
这会导致任何其他开销吗?即使是任何种类的微小开销?