#6 – An Even Smaller C# Program

In The Smallest Possible C# Program, I mentioned a couple things as optional.  For the record, here’s the absolute smallest C#.NET program that you can write.  (Assuming that you don’t need it to actually do anything).

class Program
{
    static void Main()
    {
    }
}
Advertisements

#5 – How is C# Different from VB.NET?

C# and Visual Basic .NET are both first-class languages in Microsoft’s .NET programming environment.  They both are typically run on top of Microsoft’s .NET Framework.

Most of the differences between the two languages are merely syntactic.  But there are a few meaningful differences including (but not limited to):

C# Has (VB.NET Doesn’t)

  • Can write unsafe code
  • Static classes
  • checked/unchecked
  • Auto-implemented properties
  • Case-sensitivity
  • Stricter type checking
  • Less verbose

VB.NET Has (C# Doesn’t)

  • XML literals
  • Inline date declarations
  • IsNumeric
  • Marshalling an object for multiple actions
  • Auto wire-up of events

See also: Comparison of C# and VB.NET

#4 – How is C# Different From Java?

C# and Java are both object-oriented languages that derive their syntax from C and run in a managed environment.  There are, however a number of differences.  Here are the main ones:

  • Syntactic differences, e.g. “class B extends A” instead of “class B : A”
  • Java doesn’t use namespaces
  • C# lock statement vs. Java synchronized statement
  • C# has a few more access modifiers than Java
  • In Java, enumerated types are full-fledged classes
  • C# allows strings in switch statements
  • C# programs make use of the .NET Framework; Java programs use the Java SE

Lots more at: C# From a Java Developer’s Perspective

#3 – Who Designed C#?

C# was developed by Microsoft, as part of the .NET initiative, around the year 2000.  The main designer and architect for the language was Anders Hjelsberg.

See also: C Sharp (Programming Language).

#2 – The Smallest Possible C# Program

The smallest possible C# program would consist of a static Main() function inside of a class. The namespace is actually optional, as is the args parameter.

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("2,000 Things Was Here..");
        }
    }
}



#1 – What the Main() Signature Looks Like

The standard entry point for a C# program is a static function named Main().  It typically looks like this:

static void Main(string[] args)