學校題目 不會做 求1個完整的代碼用C#做例如寫入1,它會顯示001
10,顯示010希望各位大大速度幫幫忙
10,顯示010希望各位大大速度幫幫忙
解决方案 »
- 怎样一句语Get属性返回 IEnumerable<Assembly>类型
- 删除控件求教
- C#应用程序窗口怎么禁止更改大小?
- image类型的字段,取出来保存成一个文件的例子?急!
- 怎样让窗体里的控件随窗体一起缩放??
- 一道趣味题:有一表达式62-35=1,只能移动一个数字,使之成立一个新的等式,请问该移动哪个数字
- 让你想哭却哭不出来: Math.Round(1234.56)=?
- 有哪位兄弟能介绍一本用C#写的数据结构的书看看.谢谢了!
- 如何在 WINXP/NT/2000 下用 C# 来关闭和重新启动计算机?
- 在定义的版本信息,如何读出来?
- winform窗體間的數據傳遞
- C# 调用 dll 问题,高手们帮忙解决一下。
public string Csdn(string str)
{
string newStr = string.Empty;
int i = str.Length;
if (i < 3)
{
for (int j = 0; j < 3-i; j++)
{
newStr += "0" ;
}
}
newStr += str;
return newStr;
}
class Test
{
static void Main(){
string strOut;
string strIn; Console.Write("请输入:");
strIn = Console.ReadLine();
strOut = string.Format("{0:D3}", Int32.Parse(strIn));
Console.Write("输入的是:" + strOut);
Console.ReadLine();
}
}
没有做非数字的检查哦。
Console.WriteLine(s.PadLeft(3,'0'));