eriksv88
eriksv88

Reputation: 3528

Datatype within C#

Is there a datatype within C# that if you put to for example 0001, and add 1, will be 0002?

Upvotes: 0

Views: 176

Answers (2)

Paul Mason
Paul Mason

Reputation: 1129

No, but you could emulate this functionality with an integer and:

String.Format("{0:0000}", no);

Upvotes: 5

Graviton
Graviton

Reputation: 83254

Just use int.

int i=1;
Console.WriteLine(i.ToString("0000"));
i++;
Console.WriteLine(i.ToString("0000"));

Here's the result:

0001
0002

Upvotes: 4

Related Questions