Now I still learning C#, and in one of the tutorials I found this program:
using System;
namespace Returning_a_Class_From_a_Method
{
public class MVADate
{
private int dayOfBirth;
private int monthOfBirth;
private int yearOfBirth;
public void SetDate(int d, int m, int y)
{
dayOfBirth = d;
monthOfBirth = m;
yearOfBirth = y;
}
public string ProduceDate()
{
string result = dayOfBirth + "/" + monthOfBirth + "/" +
yearOfBirth;
return result;
}
}
public class MotorVehicleAdministration
{
public MotorVehicleAdministration()
{
birthdate = new MVADate();
}
private string fullName;
private MVADate RequestDateOfBirth();
private bool isAnOrganDonor;
1! private MVADate RequestDateOfBirth()
{
MVADate date = new MVADate();
Console.Write("Day of Birth: ");
int d = int.Parse(Console.ReadLine());
Console.Write("Month of Birth: ");
int m = int.Parse(Console.ReadLine());
Console.Write("Year of Birth: ");
int y = int.Parse(Console.ReadLine());
date.SetDate(d, m, y);
return date;
}
static void Main(string[] args)
{
MotorVehicleAdministration MVA =
new MotorVehicleAdministration();
Console.WriteLine("To process a registration, enter the information");
Console.Write("Full Name: ");
MVA.fullName = Console.ReadLine();
MVA.birthdate = RequestDateOfBirth();
Console.Write("Is the application an organ donor (0=No/1=Yes)? ");
string ans = Console.ReadLine();
if (ans == "0")
MVA.isAnOrganDonor = false;
else
MVA.isAnOrganDonor = true;
Console.WriteLine("\n -=- Motor Vehicle Administration -=-");
Console.WriteLine(" -=- Driver's License Application -=-");
Console.WriteLine("Full Name: {0}", MVA.fullName);
Console.WriteLine("Dateof Birth: {0}", MVA.birthdate.ProduceDate());
Console.WriteLine("Organ Donor? {0}", MVA.isAnOrganDonor);
Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}
}
When I tried compile this program I received in line (marked by me as 1!) error :
Type Returning_a_Class_From_a_Method.MotorVehicleAdministration
already defines a member called 'RequestDateOfBirth' with the same parameter types which points to RequestDateOfBirth()
I think that error caused because of declaration
private MVADate RequestDateOfBirth();
but I still can't find any solution to this. It's tutorial, but this program won't run. What I must do to correct error?