C# question: How can I use the constructor:
AcctHolder ah1 = new AcctHolder("Dumitru", "St", "Bucharest");
and be able to obtain ah1.Fname? (instead of null)
using System;
namespace ConsoleApplication1
{
class ATM
{
public static void Main(string[] args)
{
AcctHolder ah1 = new AcctHolder("Dumitru", "St", "Bucharest");
Console.WriteLine(ah1.FName); //returns null - why???
AcctHolder ah2 = new AcctHolder();
ah2.FName = "Dumi";
Console.WriteLine(ah2.FName); // returns "Dumi"
Console.ReadKey();
}
public class AcctHolder
{
private string fname, lname, city;
public string FName { get; set; }
public string LName { get; set; }
public string City {
get { return city; }
set { city = value; }
}
public AcctHolder(string a, string b, string c)
{
fname = a;
lname = b;
city = c;
}
public AcctHolder()
{
}
}
}
}