You can't alter a class definition at runtime. However, you can create a new class that inherits from the original class (if it's not sealed
) and declares the field. You can do this by emitting the appropriate IL code using System.Reflection.Emit
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…