gpt4 book ai didi

c# - 在 C# 中是否有与 Delphi 的 "with"命令等效的命令?

转载 作者:太空狗 更新时间:2023-10-29 17:31:02 24 4
gpt4 key购买 nike

我想知道 C# 中是否有可以像 Delphi 中的 with command 一样使用的命令?

// like this :
with(textbox1)
{
.text="some text as text of text box";
.tag=1231;
}

//在德尔福中

with edit1 do 
begin
text="some text as text of edit1";
tag=1231;
end;

最佳答案

不适用于已创建的实例。

但是,当您创建一个新实例时,您可以:

var textbox1 = 
new Textbox
{
Text = "some text as text of text box",
Tag = 1231
};

关于c# - 在 C# 中是否有与 Delphi 的 "with"命令等效的命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6055552/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com