C# Reference - C# Modifiers - abstract - C# Reference - C# Modifiers - abstract
The LBTT Spot
"Lifeline is focused on developing and marketing systems designed to assist in the early detection of breast and ovarian cancer."



C# Reference - C# Modifiers - abstract

View C# Source Code

Article Categories:

.Net Framework
.Net Framework 1.1
ADO.NET
ASP.NET
Assemblies
Asynchronous Methods
C#
Collections
Configuration
Delegates
Events
Pocket PC
Regular Expressions
Smart Devices
SQL Server
Visual C#
Visual Studio .NET
Visual Studio .NET 2003
Windows Forms
XML

C# .Net Fun Menu

View Current Page's ASP.NET Source Code
C# Reference
C# Study Flash Cards
Valuable Links
Contact Us
Site Map
Mike's Portfolio

C# Reference Search:

Full Text Search:

Articles by Author:

Code Examples (zipped):

C# Reference
      C# Modifiers
           abstract


  • C# Modifiers: [abstract] Reference from Microsoft®


  • An abstract class, method or property must be derived. You can not instantiate an object from a class marked as abstract. An abstract class is said to be a base class. Remember, an abstract class or member cannot be accessed directly from that class - it can only be accessed from a deriving class. Consequently, you cannot use the sealed keyword on an abstract class. Structs cannot be abstract because the type cannot be inherited. Anything marked as abstract cannot have code defined inside of it - the deriving class must do this itself. When deriving you must use the override keyword to implement the abstracted memebers of an abstract class. private void Form1_Load(object sender, System.EventArgs e) { // this below will cause an error - we must inherit not instantiate //MyAbstractClass m = new MyAbstractClass(); // this will work MyDerivingClass mdc = new MyDerivingClass(); } // this class must implement the abstract members of the abstract class below public class MyDerivingClass : MyAbstractClass { // we must use the override keyword otherwise we use the new // keyword to implement a 'new' method of Hello2() public override String Hello2() { return "Hello #2"; } } public abstract class MyAbstractClass { public String Hello1() { return "Hello #1"; } // we can't put anything in here because it is marked as abstract // since the member is abstract so must the class be! public abstract String Hello2(); }