In this chapter you will learn:
- What is public access specifier?
- What is the boundary of public access specifier?
- How to use public access specifier in C# programming?
The class member, that is defined as public can be accessed by other class member that is initialized outside the class. A public member can be accessed from anywhere even outside the namespace.
// String Variable declared as public
public string name;
// Public method
public void print()
Console.WriteLine("\nMy name is " + name);
static void Main(string args)
access ac = new access();
Console.Write("Enter your name:\t");
// Accepting value in public variable that is outside the class
ac.name = Console.ReadLine();
Enter your name: Steven Clark
My name is Steven Clark
In this chapter you learned about what public access specifier is and what the boundary of public access specifier is. You also learned how to use public access specifier in C# programming. In next chapter you will learn about Private Access Specifier in C#.