There's no such thing as CInt in C#; it's a VB statement. In VB it will cast or convert a value to type Integer. In C# there is no overlap between casting and converting. They are distinct operations.
As to what you're trying to do there, it doesn't actually make any sense. Your 'a' variable is type int and there is no concept of leading zeroes for numerical values. Think of it this way. Hold up 9 fingers. Now hold up 09 fingers. Was there any difference? No, because the number 9 is the number 9 regardless. A number doesn't change.
You can represent the same number in many different ways. If you want to display a number to the user then you must first convert it to a string. Once you've done that you can add a leading zero if it's shorter than two digits if you want, e.g.C# Code:
int a = 5; int b = 50; MessageBox.Show(a.ToString().PadLeft(2, '0')); MessageBox.Show(b.ToString().PadLeft(2, '0'));




Reply With Quote