C# asp.net中的填充
是否有一个函数可以将填充数字附加到数字的左边。我想形成一个3位数的数字,因此当值为“3”时,我需要将其设置为“003” e、 在php中,我们有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
$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");