C#: The C# Language Specification and Hello World

If you download and install Visual Studio Professional or Ultimate you get the specification installed on your system at the directory:

And really it is an interesting read.  Really.  Ok, maybe not a beach read, but…let’s take a look at this breathtaking, griping document.  If you are into programming with Java, feel free to check Java’s ISO or ECMA standard out.  Oh you can’t.  There isn’t one a standard for Java, it’s owned by Oracle.

Hello World

If you want to get started with any language these days you start with “Hello World”.  In Part 1. Introduction, the basic Hello World is given in the example in paragraph 1.1 Hello World, which means there is a standard for “Hello World”.

Open Notepad and Copy and paste the “Hello World” example code from the Language Specification, it will look like the following without all of the goofy arrows, green box and voice bubble.

image

Compiling your code without Visual Studio

Why would you compile code without Visual Studio?  Well there are many reasons, but you might want to do an automatic build after everyone goes home for the day as an example. 

Developer Command Line, how to start

For Visual Studio 2013 in Windows 8 or Windows 8.1: reference: https://msdn.microsoft.com/en-us/library/vstudio/78f4aasd(v=vs.120).aspx

  1. On the Start screen, type Visual Studio, and then choose Visual Studio Tools. (To access the Start screen, press the Windows logo key on your keyboard.)

  2. In File Explorer, choose Developer Command Prompt for VS2013.

Compiling “Hello World” from command line

You would do this from the command line, and here is how you do it.

  1. First, make sure to save the Notepad file with the extension *.cs, for instance you might save it as: HelloWorld.cs and make sure to save it in a folder that is easy to remember or type. 
  2. Open the Developer Command Prompt if you haven’t already, it will look like this:
  3. image
  4. Navigate to the location of your “HelloWorld.CS” file -
    • image
  5. And when you “compile” the “helloworld.cs” file  it you will then see:
    • image

  6. Now you can “run” the newly generated helloword.exe file: -
    • image

  7. How would you automate your cmd line builds?
    • You would use a “Batch” file to do your builds, you could use PowerScripts or other tools to schedule the Batch file to run daily or on a schedule.

Conclusion:

This is an easy way to get started with Visual Studio if you are intimidated by the Visual Studio IDE initially, you can use Notepad to build simple applications for testing using C#.