Greg Gum
Greg Gum

Reputation: 38029

Is there a difference in initializing an int with 001 vs 1?

I ran across this sample on MSDN which uses leading zeros when initializing an int.

... new Category(){ Name="Condiments", ID=001}...

Is there a difference from just using

... new Category(){ Name="Condiments", ID=1}...

Upvotes: 1

Views: 531

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283773

No, there's no difference.

In many other C-like languages (including C itself), the leading zero would indicate an octal literal. But not in C#.

Upvotes: 7

Jon Tirjan
Jon Tirjan

Reputation: 3694

There is not, 001 is the exact same int as 1.

Upvotes: 1

Related Questions