What is C#?

     C# removes some of the complexities and pitfalls of languages such as Java and C++, including the removal of macros, templates, multiple inheritance, and virtual base classes. These are all areas that cause either confusion or potential problems for C++ developers.

First C# Program (Hello World)

using System;
class Hello
static void Main()        
Console.WriteLine("Hello world");

Type System:-

  • Value types
    • Primitives int i;
    • Enums enum State { Off, On }
    • Structs struct Point { int x, y; }
  • Reference types
    • Classes class Foo: Bar, IFoo {...}
    • Interfaces interface IFoo: IBar {...}
    • Arrays string[] a = new string[10];
    • Delegates delegate void Empty();

Predefined Types:-

  • C# predefined types
    • Reference object, string
    • Signed sbyte, short, int, long
    • Unsigned byte, ushort, uint, ulong
    • Character char
    • Floating-point float, double, decimal
    • Logical bool
  • Predefined types are simply aliases for system-provided types For example,
    • int == System.Int32