TipsOnLips.net

Your .net tips and tricks source

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010


Differences between structures and classes (C#)

   1. Structures are sealed and cannot be inherited.
   2. Structures cannot inherit classes and other structures.
   3. Structure implicitly inherits from System.ValueType.
   4. The default constructor of a structure cannot be replaced by a custom constructor.
   5. Custom constructors of a structure must fully initialize the value of the structure.
   6. Structures do not have destructors.
   7. Field initialization is not allowed. Const members of a structure can be initialized

Categories: C#
Posted by developer on Sunday, October 07, 2007 12:15 AM
Permalink | Comments (6) | Post RSSRSS comment feed

Difference between abstract classes and interfaces (C#)

An interface is similar to an abstract class. Both types must be inherited.
You cannot create an instance of either. Abstract members require implementation in the derived type.
Interface members require implementation in a derived type. Although abstract and interface members are similar,
there are several differences:

   1. An abstract class can contain some implementation. Interfaces have no implementation
   2. Abstract classes can inherit other classes and interfaces. Interfaces can only inherit other interfaces.
   3. Abstract classes can contain fields. Interfaces cannot have state.
   4. Abstract classes have constructors and destructors. Interfaces have neither.
   5. Interfaces can be inherited by structures. Abstract classes are not inheritable by structures.
   6. Interfaces support multiple inheritance. Abstract classes support single inheritance.



Categories: C#
Posted by developer on Saturday, October 06, 2007 11:21 PM
Permalink | Comments (2) | Post RSSRSS comment feed