我怎么能自动增加在C#中的数字? [英] How can I automatically increment numbers in C#?

查看:143
本文介绍了我怎么能自动增加在C#中的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#2008年Windows窗体应用程序。

I am using C# 2008 Windows Forms application.

在我的项目有一个文本框控制和我想要做的样品S00自动生成的数字,接下来我回来的时候,形成又应该增加像S01,S02,S03 ......像

In my project there is a TextBox control and in that I want make an auto generate numbers for samples s00, next when I come back to form again it should be increment like s01,s02,s03......like that

请帮我

推荐答案

相当容易。保持一个变量来保持目前的数量。

Quite easy. Keep a variable to keep the current number.

int incNumber = 0;

然后在点击按钮,产生这样的串号:

Then on click of button, generate the number string like this:

string nyNumber = "s" + incNumber.ToString("00");
incNumber++;

这篇关于我怎么能自动增加在C#中的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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