Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net中的填充_C#_Php_Asp.net - Fatal编程技术网

C# asp.net中的填充

C# asp.net中的填充,c#,php,asp.net,C#,Php,Asp.net,是否有一个函数可以将填充数字附加到数字的左边。我想形成一个3位数的数字,因此当值为“3”时,我需要将其设置为“003” e、 在php中,我们有 $m_ccode=str_pad($m_casecode,3,"0",str_pad_left); 与我想在asp.net c#中转换的相同。我该怎么做呢?我把数值存储在字符串's'中 String s = DropDownList3.SelectedItem.Value; 请尝试以下操作: String s = DropDownList3.Sel

是否有一个函数可以将填充数字附加到数字的左边。我想形成一个3位数的数字,因此当值为“3”时,我需要将其设置为“003”

e、 在php中,我们有

$m_ccode=str_pad($m_casecode,3,"0",str_pad_left);
与我想在asp.net c#中转换的相同。我该怎么做呢?我把数值存储在字符串's'中

String s = DropDownList3.SelectedItem.Value;
请尝试以下操作:

String s = DropDownList3.SelectedItem.Value.PadLeft(3, '0');
在您的情况下,如果数值是
int

String s = ((int)DropDownList3.SelectedItem.Value).ToString("000");
String s = ((int)DropDownList3.SelectedItem.Value).ToString("000");