Beginning C#: Part 1 – A Simple Example

Today was my first day working for the State of Montana as a Programmer.

It turns out that my first week is going to be a week of training (today was the first day). They hired a training course company called DevelopMentor to come in and train the programmers on C# and using LINQ. From my understanding, LINQ is basically a way of making data “objects” that can be accessed directly from memory. There are a lot of speed and functionality benefits to doing it this way.

Lucky for me C# is not too much different from PHP…at least in general syntax. How programs are written is quite a bit different than PHP, and it is much more strict in variable usage. I like this because it is not so easy to write horribly ugly and unmaintainable code in C# as it is in PHP. There are a lot of things I need to learn in regards to the language, especially considering C# and .NET is part of what I will be programming in my new job.

I really like Visual Studio 2008 with Intellisense. At first I thought that I may have to purchase software, but I think the Express Editions will work fine for learning the language at home. At work I’ve got the full version of the software.

With that said, I thought it would be fun to start posting some basic C# examples. I hope this would be useful to some people, but I also want to do this so that I can get more familiar with the language.

One of the first things I am trying to get used to with C# is the strict variable typing and how to work with arrays and loops. Here is a very basic loop that goes through an array and prints the string to the console:

static void Main(string[] args)
    string[] mywords = new string[5] { "one", "two", "three", "four", "five" };
    foreach (string word in mywords)
        Console.WriteLine("Word: {0}", word);

The teacher of the class we are taking has a very useful C# article. The basics of C# article can be found here: