Monday, May 31, 2010

String, string, Byte, byte, int, Int32....

I have often wondered while typing “string” in Visual Studio (the IntelliSense shows string and String), what’s the difference between a string and String? NONE

Then why have two names for the same data type? One is the Base Class Library (BCL) name(String) and the other is a short form for it. Since these basic data types are frequently used we are given short forms which are much easier to use e.g. int for Int32.

For the compiler it doesn’t make any difference, whether you had used an int or Int32. Consider the IL (Intermediate Language) for the following piece of code:



IL Code:

Saturday, May 8, 2010

Using the Command prompt to run C# program

For those of us who had gone on the fast track to learn C# (remember I was into java before the leap to .NET) Visual Studio IDE does a great job in encapsulating the details. For a beginner it just looks great, just write your code, hit F5 (or) run. You are done! But as you move on you begin to wonder how do you do it the old fashioned way (Command Line)?

That's exactly what I discovered learning C# 4.0. You have this tool called csc.exe (like javac), Go to your Visual Studio command prompt, navigate to the folder that has you program and do this:

> csc.exe yourprogramname.cs

This compliles your code and generates an exe. You can run your code using:
> youprogramname.exe

Replace yourprogramname with the name of your program.