7
Answers

Access modifier

Maha

Maha

11y
1.3k
1
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)