简体   繁体   English

批量设置一个类的所有字符串属性为空

[英]Set all string properties of a class to empty in batch

The C# class have 20 properties in string. C# 类在字符串中有 20 个属性。 After some code execution, some of the properties are assgined value.在一些代码执行之后,一些属性被赋值。 Now I need a Clear() method to set all of them into string.Empty .现在我需要一个Clear()方法将它们全部设置为string.Empty I can write 20 lines of code, just assgin string.Empty to them one by one.我可以写20行代码,只是assgin string.Empty一一给他们。 But that will be a lot of lines in the class file.但这将是类文件中的很多行。

Is there any good way to do this?有什么好的方法可以做到这一点吗? Thanks.谢谢。

只是为了笑;)

string1 = string2 = string3 = string4 = string5 = string6 = string7 = string8 = string9 = string10 = string11 = string12 = string13 = string14 = string15 = string16 = string17 = string18 = string19 = string20 = string.Empty;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM