有没有办法在 Windows 窗体 C# 中通过一个声明设置多个属性?
我正在为游戏制作技能计算器,我希望能够做这样的事情:
someControl.Text = "some text",
.BackgroundImage = "someImage.jpg";
有没有可能做这样的事情?
最佳答案
在 VB 中,您可以使用“WITH”关键字。 C# 中最接近的是采用对象初始值设定项的构造函数。
var someControl = new Control() {
Text = "SomeText",
BackgroundImage "someImage.jpg" };
但是不,我不认为有一种方法可以在 C# 中完成您的要求。
关于c# - 在 Windows 窗体 (C#) 中使用一个声明设置多个属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17032663/