Maha

Maha

  • NA
  • 600
  • 70.8k

Whether it is possible

Dec 3 2014 8:29 AM
http://www.c-sharpcorner.com/Forums/Thread/277334/constructor-body.aspx

I wish to know whether it is possible to do in the following program the way code is highlighted in the above web page. Problem is coloured.

using System;
public class CreateEmployee
{
public static void Main()
{
int id = 345;

Employee myAssistant = new Employee(id);

Console.WriteLine("ID # is {0}", myAssistant.GetId());

Console.ReadKey();
}
}
internal class Employee
{
private int idNumber;

public Employee(Employee myA)
{
idNumber = myA.idNumber;
}
public int GetId()
{
return idNumber;
}
}
// ID # is 345


Answers (9)