繁体   English   中英

通过诸如命令提示符之类的界面进行命令

[英]Commands through an interface like Command Prompt

我想知道是否有一种方法可以在不使用switch或if语句的情况下将用户形式的输入作为命令运行?

例如,如果我有一个包含10 x 10相框的表单,并且想要将其大小更改为100 x100。更好的是,有没有一种方法可以使用代码中定义的stringstring newString = ""; 然后更改所述字符串的名称: newString = "newButton" + count;

该代码将像这样使用:

   for (int count = 0; count < records) // Records being the count of records to   be presented.
          { 
            newString = "newButton" + count;
            Button newString.ToString() = new Button();
          } //Uses the newString to give      ID name to the new buttons.

与此类似的事情是使用Java代码使用<tag>out_print命令为servlet创建表。

似乎您正在寻找Dictionary<T,T> 您可以像这样实现您的循环想法:

var buttons = new Dictionary<string,Button>();
for (int count = 0; count < records)
{ 
    newString = "newButton" + count; 
    var newButton = new Button();
    buttons.Add(newString, newButton);
} 

暂无
暂无

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

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