Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Thursday, 4 November 2010

Partial Classes, Interfaces & Generics


Partial classes can be used to split definitions of classes, structs or interfaces over two or more source files. Each source file contains a section of the class definition which are combined at when the application is compiled.


Partial classes can be beneficial in the following situations:

  • Working on large projects, allowing developers to work on different sections of a class without both having to access the same physical file. 
  • Working with generated source code, as code can be added to a class without touching the original source file. 
  • Improve maintainability by logically grouping code.

An interface is a contract between classes. An interface is particularly powerful in C# as it allows multiple inheritance.

Interfaces are abstract types that contain no actual data but simply expose behaviours to the classes that implements them.

Generics use type parameters, which allow classes and methods that can defer specification until they are instantiated.
  • Maximises code reuse, type safety and performance. 
  • Most common use in collections
Read rest of entry

Friday, 29 October 2010

C# System Types

The type system in .NET or Common Type System (CTS) divides types into 2 categories:
  • Values Types
  • Reference Types
Value Types

These are simple data types that directly contain their data, for example:
  • Integers
  • Floats
  • Enums
  • Structs
Reference Types

These types store references to objects.  Reference type variables have the ability to refer to the same data, so two variables can point to same object and the object be manipulated by performing operations of both variables.  Examples include:
  • Classes
  • Interfaces
  • Delegates
  • Arrays
Read rest of entry
 

Popular Posts

developer-express Copyright © 2009 Black Nero Blogspot Templatesis Designed by Ipietoon Sponsored by Online Business Journal