Programming in C# Assemblies in C# .[dot]net


Programming in C# Assemblies 



Assemblies
•         Code contained in files called “assemblies”
–        code and metadata
–        .exe or .dll as before
–        Executable needs a class with a “Main” method:
•       public static void Main(string[] args)
–        types
•       local: local assembly, not accessible by others
•       shared: well-known location, can be GAC
•       strong names: use crypto for signatures
–        then can add some versioning and trust        
PE executable file  :





Manifests and Assemblies  :





First C# Program :


using System;
namespace Test
{
class ExampleClass
{
   static void Main()
   {
      System.Console.WriteLine("Hello, world!");
   }
}
}


Constructions of Note :
•       using
–        like import in Java: bring in namespaces
•       namespace
–        disambiguation of names
–        like Internet hierarchical names and C++ naming
•       class
–        like in C++ or Java
–        single inheritance up to object
•       static void Main()
–        Defines the entry point for an assembly.
–        Four different overloads – taking string arguments and returning int’s.
•       Console.Write(Line)
–        Takes a formatted string: “Composite Format”
–        Indexed elements: e.g., {0}
•       can be used multiple times
•       only evaluated once
–        {index [,alignment][:formatting]}


Comments