By 19/02/2016 22 Comments

Default Access Modifiers In C#.NET

  • In C#.NET everything (methods,┬ávariables, properties etc) are declared as private by default.

Example:

using System;

namespace Examples
{
 class Test
 {
 // Following void type method and field name is declared as private by default.
 string SiteName = "tutorialstown.com";
 void displayMsg()
 {
 Console.WriteLine("displayMsg() is being called");
 }
 }
 class Program
 {
 static void Main(string[] args)
 {

 Test test = new Test();

 // Trying to call following members will cause compile-time error.
 // test.displayMsg();
 // Console.WriteLine(test.SiteName);

 Console.ReadKey();
 }
 }
}






Posted in: C#.NET, Solutions

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .