Assignment:
Q: Below is the code created for this Visual C# .Net project. How do you get the First name and last name? Code does show me Salesperson's full name. Can you correct the code so that it will show the first name, last name and then full name as per instructions.
Below is the instructions given:
1. Create an abstract class names Salesperson.
2. Include the following fields in abstract class Salesperson which are required
by the Salesperson
constructor.
- First name
- Last name.
Include a get method the returns a string that holds the salesperson's full name, which consists of the first and last names separated by a space.using System;
namespace MyApplication
{
abstract class Salesperson
{
protected string name;
public Salesperson(string name)
{
this.name = name;
}
public string GetName()
{
return name;
}
}
class MainClass : Salesperson
{
public MainClass(string name) : base(name)
{
}
static void Main(string[] args)
{
MainClass mobj=new MainClass("Ricky Ponting");
Console.WriteLine(mobj.GetName());
Console.Read();
}
}
}