Maha

Maha

  • NA
  • 0
  • 324.9k

Access modifier

Jul 12 2013 8:28 PM
In the this program if you write public in front of 

static void Display(Employee num) program is not executing. Please tell me the reason. Problem is highlighted. 

But internal access modifier instead of public in the program is executing. 

using System;
public class CreateEmployee
{
public static void Main()
{
Employee myAssistant = new Employee();

myAssistant.SetId(345);

Display(myAssistant);

Console.ReadKey();
}
static void Display(Employee num)
{
Console.WriteLine("ID # is {0}", num.GetId());
}
}

internal class Employee
{
private int idNumber;

public int GetId()
{
return idNumber;
}
public void SetId(int id)
{
idNumber = id;
}
}
// ID # is 345


Answers (7)