从文本框获取Int值,假设我输入5然后结果将是1,2,3,4,5 ...? [英] Get Int Value From Textbox, Suppose I Enter In 5 Then Result Will Be 1,2,3,4,5... ?

查看:60
本文介绍了从文本框获取Int值,假设我输入5然后结果将是1,2,3,4,5 ...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#winforms。假设我输入值5,我想在这样的消息框中得到一个结果1,2,3,4,5请告诉我最佳解决方案。

c# winforms . suppose I enter in value 5 , I want a result in Message box like this 1,2,3,4,5 please tell me best solution.

推荐答案

我会给你指路,但你必须自己努力:

1.在winform中创建一个文本框,让用户输入一个整数,比如5

2.创建一个从1到整数的循环

3.在每个循环中,比如在第3个循环,将当前循环计数(3)转换为字符串并将其与前一个连接循环计数(1,2),例如1,2,3

4.在整个循环结束时,将结果显示在消息框中,例如1,2,3,4,5

结束。

参考:

1. For Loop [ ^ ]

2. Messagebox-show [ ^ ]

3.整数到字符串转换和字符串连接,问Google。
I will show you the way, but you have to put in effort to do it yourself:
1. Create a textbox in the winform to let user enter an integer number, say 5
2. Create a loop that starts from 1 to that integer number
3. At each loop, say at the 3rd loop, convert the current loop count (3) to string and concatenate it with the previous loop counts (1,2), e.g. 1,2,3
4. At the end of the whole loop, show the result in a message box, e.g. 1,2,3,4,5
The End.
Refer:
1. For Loop[^]
2. Messagebox-show[^]
3. Integer to String conversion and string concatenation, Ask Google.


你要循环从1开始循环并以文本框中输入的值结束。



显示所有结果values在循环中创建一个逗号分隔的字符串。
you've to iterate a loop from starting with 1 and ending with the value entered in the textbox.

to display the result for all values make a string with comma separated within the loop.


这篇关于从文本框获取Int值,假设我输入5然后结果将是1,2,3,4,5 ...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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