[英]How can I set new instance for a property class in C#.
Actually I want to reset the SpintexEditorProperty class. 实际上,我想重置SpintexEditorProperty类。 This contains the static properties.
这包含静态属性。 I want to reset all those properties so that i set new instance but it is not functioning... Please help me... Thanks in advance!
我想重置所有这些属性,以便我设置新实例,但是它不起作用...请帮助我...预先感谢!
//Reset the SpintexEditorPropertyMain //重置SpintexEditorPropertyMain
internal static void ResetSpintexEditorPropertyMain()
{
SpintexEditorPropertyMain = new SpintexEditorProperty();
}
If class contains static properties then directly access the properties, you don't have to create a new instance to change static properties 如果类包含静态属性,则直接访问属性,则无需创建新实例来更改静态属性
Example SpintexEditorProperty.propertyname = null, this will reset the property 示例SpintexEditorProperty.propertyname = null,这将重置属性
Static properties are not reset when you create a new instance of the class containing those properties. 创建包含这些属性的类的新实例时,不会重置静态属性。 Static fields are meant to remain the same for all the instances of that class.
对于该类的所有实例,静态字段均应保持不变。
if you want to reset their values you will have to do them explicitly. 如果要重置其值,则必须显式地进行设置。 Something like this.
这样的事情。
public static void ResetStaticProperties()
{
SpintexEditorProperty.Property1 = 0;
SpintexEditorProperty.Property2 = 0;
SpintexEditorProperty.Property3 = 0;
}
and call this method whereever you want to reset them 并在您想重置它们的任何地方调用此方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.