C#

C# was originally designed by Microsoft as an application development language and thus has many features in common with Java. It is now standardised and there are several implementations that run on a variety of platforms. C# is a statically typed imperative programming language with both functional and object oriented features.

Why would I learn this language?

C# is a modern, fully featured programming language. It is built on top of the CLR which provides a wide range of APIs from 3D graphics to databases.

Specifically, using Mono.NET it is possible to develop cross-platform desktop applications, web applications and games.

Starting Points

Introduction to developing with Mono
A short guide to C# including a Hello World example.

Example Code

The following is an example of the Fizz Buzz problem. You can run and edit this program here.

using System;
namespace FizzBuzz {
    public class example {
        static void Main(string[] args) {
            for (int i = 1; i <= 100; i++) {
                if (i % 3 == 0 && i % 5 == 0) {
                    Console.WriteLine("FizzBuzz");
                } else if (i % 3 == 0) {
                    Console.WriteLine("Fizz");
                } else if (i % 5 == 0)  {
                    Console.WriteLine("Buzz");
                } else {
                    Console.WriteLine(i);
                }
            }
        }
    }
}

The following is an example of the 100 doors problem. You can run and edit this program here.

using System;
class Program
{
	static void Main()
	{
		// Initialize a vector of n boolean values
		bool[] doors = new bool[100];
		
		// Process the doors
		for (int pass = 0; pass < 100; pass++)
			for (int current = pass; current < 100; current += pass+1)
				doors[current] = !doors[current];

		// Print out the results
		for (int i = 0; i < 100; i++)
			Console.WriteLine("Door #{0} " + (doors[i] ? "Open" : "Closed"), i);
	}
}

Further Reading

comments powered by Disqus