我试图从SalesPerson
对象返回一个字符串fullNameMethod
到主程序,但这不起作用。我究竟做错了什么?
class SalesPerson
{
string firstName, lastName;
public string FirstName { get { return firstName; } set { firstName = value; } }
public string LastName { get { return lastName; } set { lastName = value; } }
public SalesPerson(string fName, string lName)
{
firstName = fName;
lastName = lName;
}
public string fullNameMethod()
{
string x = firstName + " " + lastName;
return x;
}
}
class Program
{
static void Main(string[] args)
{
SalesPerson x = new SalesPerson("john", "Doe");
Console.WriteLine("{0}", x.fullNameMethod);
}
}