Geeks With Blogs
Austin's Pad Who's on first? .Net

A while back I was working on a project with Microsoft when we had a visit from someone on the Microsoft .net CLR product team.  This person coded examples and when he defined his variables he used “Int32” vs. “int” and “String” vs. “string”.  I had remembered seeing this style in other example code from Microsoft.  So, I did some research and found that everyone says that there is no difference between the “Int32” and “int” except for syntax coloring.  In fact, I found a lot of material suggesting you use “Int32” to make your code more readable.  So, I adopted the style.

 

The other day I did find a difference!  The compiler doesn’t allow you to type enum using the “Int32” but it does when you use “int”.  Don’t ask me why because I don’t know yet.

 

Example:

public  enum MyEnum : Int32

{

    AEnum = 0

}

 

This works.

 

public enum MyEnum : int

{

    AEnum = 0

}

Posted on Friday, August 5, 2005 6:42 AM General | Back to top


Comments on this post: Int32 notation vs. int

# re: Int32 notation vs. int
Requesting Gravatar...
How weird? I guess you tried with VS.NET 2003 but it also repros with VS2005. Fully qualifying System.Int32 or switching between debug/release builds makes no difference. Have you logged a bug at the feedback center? I'd be interested to find out why...

[aside: VB doesn't have this issue as it does not support enum inheritance]
Left by Daniel Moth on Aug 06, 2005 4:25 AM

# re: Int32 notation vs. int
Requesting Gravatar...
I added this to the product feedback center. I will be interested to see what Microsoft says about this.

Note: If this comment happens then for some reason .text doesn't like the URL for my created feedback article to be put in the body of this comment so I put the URL in the URL field for this comment.
Left by Austin on Aug 08, 2005 6:52 PM

# re: Int32 notation vs. int
Requesting Gravatar...
Just in case someone is wondering what the outcome of my product feedback to Microsoft was.

Microsoft closed the issue stating that this is by design and that the value add of this type of change does not justify the added complexity to the compiler.

I can agree with that from a business perspective.
Left by Austin on Aug 12, 2005 11:34 AM

# re: Int32 notation vs. int
Requesting Gravatar...
holy gaucamole!!
Left by Lawanya on Apr 02, 2008 3:15 PM

Your comment:
 (will show your gravatar)


Copyright © Chris Austin | Powered by: GeeksWithBlogs.net | Join free