Demonstrates deriving a new class from a base class in another assembly : Class Deriving « Class Interface « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Class Interface » Class DerivingScreenshots 
Demonstrates deriving a new class from a base class in another assembly
Demonstrates deriving a new class from a base class in another assembly

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/

//
//  Access1.cs - demonstrates deriving a new class from a base class in
//               another assembly. Also demonstrates how a derived class
//               may provide a public property to expose a protected member
//               of a base class.
//
//               Compile this program with the following command line:
//                   C:>csc /r:access.exe Access1.cs
//
namespace nsAccess
{
    using System;
    
    public class Access1
    {
        static public void Main ()
        {
            clsDerived derived = new clsDerived ();
            derived.AccessIt = 42;
            derived.ShowField ();
        }
    }
//
// Derive a class from the base class and give it a public
// property to access the private field in the base class
    class clsDerived : clsBase
    {
        public int AccessIt
        {
            get {return (Private);}
            set {Private = value;}
        }
    }
    public class clsBase
    {
        private int m_Private;
        protected int Private
        {
            get {return (m_Private);}
            set {m_Private = value;}
        }
        public void ShowField ()
        {
            Console.WriteLine ("The value of private field m_Private is " + m_Private);
        }
    }
    
}


           
       
Related examples in the same category
1.the overridden methods of the System.Object class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.