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

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Language Basics » 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
w_w___w__._ja___v_a2s.___c_o_m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.