English 中文(简体)
从Combo盒中翻开两位数,翻开两位数
原标题:Converting from Combobox double digit to int double digit
  • 时间:2012-04-11 15:43:39
  •  标签:
  • c#
  • int
Min = Convert.ToInt32(cbMin.SelectedItem);

我在此提出这个问题,利用这条线将 com子转换成ger变。 现在,如果从我的下降中选择“00”或“05”价值,只算出“0”或“5”,那么,只有在出现“0”的裁武条约数量时,才会发生。

哪怕是失踪?

PS:顺便说一句,当我安装了“ com”箱时,我就在一边使用该财产部分并填写了收集。 只是想确定,我会把这一点从那里删除。

最佳回答

如果你想要引导零,利用扼杀手段,将潜在价值转换为愤怒

i.ToString("00")

努力为你们工作

最后法典

string s = (Convert.ToInt32(cbMin.SelectedItem)).ToString("00")

http://www.ohchr.org。

如果你们的伤 to与你只需要写字

string Min = cbMin.SelectedItem.ToString();
问题回答

Integers don t have leading zeros. They are numeric data types. The leading zero is only possible in a string data type.

  • int 0 is not the same as string "0"
  • int 1 is not the same as string "1"

如果你需要以最高数值来计算,并且永远不使用该数值,那么你就应当把它作为指示。 先是将它转化为暗中。

如果你需要做计算,那么,你需要将其转换为固定的,但在你需要主导零的地方。 将其转而采用数据格式,以达到领先的零。

"1".ToString("00") will result in "01".

15>ToString ("00”) will result in “15.

关于数字数据类型的更多信息,见以下文件:here和习俗Numeric Format Strings(如上例所示)文件

C#上,无谓地将“<>5>作为<0>>>0。 但是,如果想有这种形式的话,你可以做到:

string Min = Convert.ToInt32(cbMin.SelectedItem).ToString("00");

string Min = String.Format("{0:0#}", Convert.ToInt32(cbMin.SelectedItem));




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签