我该怎么把它放在循环中 [英] How Do I Put This In Loop

查看:67
本文介绍了我该怎么把它放在循环中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我怎么把这个循环放在哪里如果用户点击构建按钮,Plot 2将变为Plant 2,Plot 3将出现在Plant 2下方,其风格与Plot 2相同/>


这是PLOT 2

Hi guys how do i put this a loop where if user clicks build button, "Plot 2" will change to "Plant 2" and "Plot 3" will appear below "Plant 2" with same style like Plot 2

This is PLOT 2

message.AppendLine();
message.AppendLine("Plot 2");
message.Append(string.Format("$:{0} ", Cash), Color.Gray, TextMarkup.FontDecrease);
message.Append(string.Format("F:{0} ", Food), Color.Gray, TextMarkup.FontDecrease);
message.Append(string.Format("C:{0} ", Concrete), Color.Gray, TextMarkup.FontDecrease);
message.AppendLine(string.Format("M:{0}", Metal), Color.Gray, TextMarkup.FontDecrease);
message.AppendLine(string.Format("Time: {0}", Time), Color.Gray, TextMarkup.FontDecrease);
message.AppendLine(MessageBuilder.Elements.CreateLink("btnBuild", "Build", ""));

推荐答案

:{0},现金),颜色。 Gray,TextMarkup.FontDecrease);
message.Append( string .Format( F:{0},Food),Color.Gray,TextMarkup.FontDecrease);
message.Append( string .Format( C:{0},Concrete),Color.Gray, TextMarkup.FontDecrease);
message.AppendLine( string .Format( M:{0},Metal),Color.Gray,TextMarkup.FontDecrease);
message.AppendLine ( string .Format( 时间:{0} ,Time),Color.Gray,TextMarkup.FontDecrease);
message.AppendLine(MessageBuilder.Elements.CreateLink( btnBuild Build ));
:{0} ", Cash), Color.Gray, TextMarkup.FontDecrease); message.Append(string.Format("F:{0} ", Food), Color.Gray, TextMarkup.FontDecrease); message.Append(string.Format("C:{0} ", Concrete), Color.Gray, TextMarkup.FontDecrease); message.AppendLine(string.Format("M:{0}", Metal), Color.Gray, TextMarkup.FontDecrease); message.AppendLine(string.Format("Time: {0}", Time), Color.Gray, TextMarkup.FontDecrease); message.AppendLine(MessageBuilder.Elements.CreateLink("btnBuild", "Build", ""));


您可以保留要在变量中生成此模式的次数。 (如果每次点击按钮时此值都在增加,则可以使用全局变量来保持计数...比如maxCount)然后你可以按如下方式循环:



You can keep a count of number of times you want to generate this pattern in a variable. (If this value is increasing everytime button is clicked, global variable can be used for keeping the count ... say maxCount) and then you can loop it as below:

for (int i = 0; i < maxCount; i++)
            {
                message.AppendLine();

                if (i==maxCount-1)
                    message.AppendLine("Plot " + i+1);
                else
                    message.AppendLine("Plant " + i+1);

                message.Append(string.Format("


:{0},Cash),Color.Gray,TextMarkup.FontDecrease);
message.Append( string .Format( F:{0},Food),Color.Gray,TextMarkup.FontDecrease);
message.Append( string .Format( C:{0},Concrete),Color.Gray,TextMarkup.FontDecrease);
message.AppendLine( string .Format( M:{0},Metal),Color.Gray,TextMarkup.FontDecrease);
message.AppendLine( string .Format( 时间:{0},时间),Color.Gray,TextMarkup.FontDecrease);
message.AppendLine(MessageBuilder.Elements.CreateLink( btnBuild Build ));
}
:{0} ", Cash), Color.Gray, TextMarkup.FontDecrease); message.Append(string.Format("F:{0} ", Food), Color.Gray, TextMarkup.FontDecrease); message.Append(string.Format("C:{0} ", Concrete), Color.Gray, TextMarkup.FontDecrease); message.AppendLine(string.Format("M:{0}", Metal), Color.Gray, TextMarkup.FontDecrease); message.AppendLine(string.Format("Time: {0}", Time), Color.Gray, TextMarkup.FontDecrease); message.AppendLine(MessageBuilder.Elements.CreateLink("btnBuild", "Build", "")); }


这篇关于我该怎么把它放在循环中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆