Maha

Maha

  • NA
  • 0
  • 326.4k

access specifier public & internal

Jul 20 2012 10:26 AM
In this program class GirlScout's (highlited in yellow) access specifier is internal by default. If access specifier is change into public the program is giving same output. Please tell me the purpose of having internal.

using System;

namespace ConsoleApplication1
{
class DemoScout
{
static void Main(string[] args)
{
GirlScout x = new GirlScout("Rose", 2000, 20.50);
GirlScout y = new GirlScout("Mary", 3000, 45.50);

Console.WriteLine("Name:{0} Troop NO:{1} Owed:${2} Motto:{3}", x.GetName(), x.GetTno(), x.GetOwed(), GirlScout.motto);
Console.WriteLine("Name:{0} Troop NO:{1} Owed:${2} Motto:{3}", y.GetName(), y.GetTno(), y.GetOwed(), GirlScout.motto);

Console.ReadKey();
}
}
}
class GirlScout
{
string name;
int tno;
double owed;
public const string motto = "to obey the Girl Scout law";

public GirlScout(string name, int tno, double owed)
{
this.name = name;
this.tno = tno;
this.owed = owed;
}

public string GetName()
{
return this.name;
}
public int GetTno()
{
return this.tno;
}
public double GetOwed()
{
return this.owed;
}
}
/*
Name:Rose Troop NO:2000 Owed:$20.5 Motto:to obey the Girl Scout law
Name:Mary Troop NO:3000 Owed:$45.5 Motto:to obey the Girl Scout law
*/


Answers (3)