SunQuest
 
       C#
  Home arrow C# arrow Page 5 - Defining Member and Type Visibility
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Defining Member and Type Visibility
By: Ayad Boudiab
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-16

    Table of Contents:
  • Defining Member and Type Visibility
  • Public Members
  • Private Members
  • Protected Members
  • Internal and Protected Internal Members
  • Type Visibility

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Defining Member and Type Visibility - Internal and Protected Internal Members


    (Page 5 of 6 )

    As far as internal and protected internal members go, they are mostly useful when you are creating libraries (managed dlls). internal defines members that are accessible by any type in the same assembly. protected internal defines a member whose access is limited to the current assembly or to types derived from the defining class in the current assembly. Here is an example that illustrates their use:


    class Program

    {

    static void Main(string[] args)

    {

    MyClass c = new MyClass();

    c.MyInternalMethod();

    c.MyProtectedInternalMethod();

    }

    }


    class MyClass

    {

    internal void MyInternalMethod()

    {

    Console.WriteLine("I am an internal method");

    }


    protected internal void MyProtectedInternalMethod()

    {

    Console.WriteLine("I am a protected internal method");

    }

    }


    After discussing member visibility, one question comes up: how about type visibility? Should the class be accessed by other classes outside the assembly, or should its accessibility only be limited to the defining assembly?

    When it comes to type visibility, there are two access modifiers of concern: public or internal.

    More C# Articles
    More By Ayad Boudiab


       · Hello everyone,Welcome to my first article of the series of introduction to C# and...
     

    C# ARTICLES

    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#
    - Working with Windows Registry in C#
    - Lossless Image Resizing in C#
    - Lossless Image Converting in C#
    - Creating an RSS Feed with ASP.Net Written in...
    - Polymorphism in C#
    - Inheritance in C#
    - C# Events Explained
    - C# Delegates Explained
    - C# StreamReader and StreamWriter Explained
    - C# FileStream Explained

    Click Here




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway