
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What is the default access for a class in C#?
If no access modifier is specified, then the default is Internal. Internal access specifier allows a class to expose its member variables and member functions to other functions and objects in the current assembly. In other words, any member with internal access specifier can be accessed from any class or method defined within the application in which the member is defined.
The following is an example showing the usage of Internal access specifier −
Example
using System; namespace RectangleApplication { class Rectangle { //member variables internal double length; internal double width; double GetArea() { return length * width; } public void Display() { Console.WriteLine("Length: {0}", length); Console.WriteLine("Width: {0}", width); Console.WriteLine("Area: {0}", GetArea()); } }//end class Rectangle class ExecuteRectangle { static void Main(string[] args) { Rectangle r = new Rectangle(); r.length = 4.5; r.width = 3.5; r.Display(); Console.ReadLine(); } } }
Output
Length: 4.5 Width: 3.5 Area: 15.75
- Related Articles
- What is the default access for a class member in C#?
- What is Default access level in Java?
- What is the scope of default access modifier in Java?
- default access modifier in Java
- What happens when more restrictive access is given to a derived class method in C++
- What is the default constructor in C#?
- What are the differences between protected and default access specifiers in Java?
- What is the base class for all exceptions in C#?
- C++ Program to Access private members of a class
- What is default constructor in C# programs?
- What are private, public, default and protected access Java modifiers?
- What is the base class for all data types in C#.NET?
- What is a base class in C#?
- What is a sealed class in C#?
- What is a static class in C#?

Advertisements