0

switchやifステートメントを使用せずに、ユーザーからの入力をコマンドとして実行する方法があるのだろうかと思っていました。

たとえば、10 x 10の額縁を含むフォームがあり、そのサイズを100 x 100に変更したい場合はstring、コードで定義されている を使用する方法があります。string 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コマンドを使用してサーブレットのテーブルを作成することです。

4

1 に答える 1

1

多分あなたが探しているようです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);
} 
于 2012-09-03T02:32:05.190 に答える