About the language

C# is a type-safe, object-oriented language designed by Anders Hejlsberg for Microsoft as an answer to Sun Java. It shares a lot of common features with Java. In fact my opinion is that if you know Java, you already know C#.

An Interview with Anders Hejlsberg about C#

About the hype

C# is regarded as another Microsoft monster by the Open Source community and it is actually the case. C# is the standard language of the .NET development platform, whose ambition is to become the dominant player in the software development industry. This is bad especially because .NET is currently distributed only on Windows.

But few people actually know that a part of .NET is an official ECMA standard. It's unusual from Microsoft to standardise parts of something that will help conquer the world. If anyone understands anything about their strategy relating to this, please explain it. Microsoft released the standardised part of .NET on FreeBSD. It's called Rotor and it is released under a shared-source (ie: look but don't touch) licence.

Nonetheless, if you forget about the company that engineered C# and .NET and their goals, it turns out that both are very pleasant to use for a programmer on the Win32 platform. You can download the .NET Framework SDK for free from Microsoft and start programming for the .NET platform.

.NET Framework SDK download
Shared Source CLI (Rotor)

.NET on Linux

Yes, it is true! Miguel de Icaza leads a project that aims to port the .NET platform and all the related tools to Linux. It's called Mono and its already usable for Open Source .NET projects. It's available for Windows, *NIX and MacOS. It is unclear, however, in what way the software patents that Microsoft has put on its API's won't prevent alternative implementations of the .NET platform to be finalized. http://www.go-mono.org

A C# sample

Until we do better, here is something copied from http://www.cfdev.com/code_samples/code.cfm/CodeID/39/c/C__Properties_Example. This will look familiar to all C++ and Java programmers.

using System;

namespace MyNameSpace
{
      public class Foo 
      {
            public Foo() { x = 0; }

            private int x;

            public int X {
                  get {
                        return x;
                  }
                  set {
                        if (value > 0) {
                              x = value;
                        }

                        else { x = 0; }
                  }
            }

            static void Main(string[] args) {
                  Foo f = new Foo();

                  f.X = 7;
                  Console.WriteLine("x = {0}", f.X);

                  f.X = -3;
                  Console.WriteLine("x = {0}", f.X);
            }
      }
}

A C# Windows Sample

This will display an empty window, about 100x100 big.

using System;
using System.Windows.Forms;

namespace WindowsApp
{
        public class Form1 : System.Windows.Forms.Form
        {
                public Form1()
                {
                }

                static void Main() 
                {
                        Application.Run( new Form1() );
                }
        }
}

CSharpLanguage (last edited 2008-07-09 05:47:51 by localhost)