Click here to Skip to main content
15,896,154 members
Home / Discussions / C#
   

C#

 
GeneralRe: Understanding changes of the mouse icon Pin
V.23-Sep-13 3:35
professionalV.23-Sep-13 3:35 
GeneralRe: Understanding changes of the mouse icon Pin
Eddy Vluggen23-Sep-13 5:50
professionalEddy Vluggen23-Sep-13 5:50 
AnswerRe: Understanding changes of the mouse icon Pin
BillWoodruff23-Sep-13 4:55
professionalBillWoodruff23-Sep-13 4:55 
AnswerRe: Understanding changes of the mouse icon Pin
Pete O'Hanlon23-Sep-13 7:07
mvePete O'Hanlon23-Sep-13 7:07 
GeneralRe: Understanding changes of the mouse icon Pin
ExcellentOrg23-Sep-13 8:23
ExcellentOrg23-Sep-13 8:23 
GeneralRe: Understanding changes of the mouse icon Pin
Pete O'Hanlon23-Sep-13 8:41
mvePete O'Hanlon23-Sep-13 8:41 
GeneralRe: Understanding changes of the mouse icon Pin
ExcellentOrg25-Sep-13 20:05
ExcellentOrg25-Sep-13 20:05 
GeneralExample 5-14 - Drill 5-3 Pin
N8tiv23-Sep-13 0:51
N8tiv23-Sep-13 0:51 
"Make the necessary changes to Example 5-14 to make the Employee
class a subclass of the Citizen class. Display some properties from
the Citizen class, such as the SSN and Age. The output should look
something like:

Citizen's Information:
SSN: 555-55-5555
Age: 36

Job Information:
Company Name: Pille Mandla
Company ID: 123-WxYz"

I'm about halfway done with my certification e-book/course… This was one of the little homework assignments…
I realize I could have done it two different ways, I was wondering if there was any other way of accomplishing this…
I realize it is just a simple program, but… As far as performance wise (let's pretend it's a larger program), which way is the most optimal?

Here is what I done:
C#
using System;

public class Citizen
{
    private string ssn;
    private string age;

    public string SSN
    {
        get { return ssn; }
        set { ssn = value; }
    }
    public string Age
    {
        get { return age; }
        set { age = value; }
    }
    public void DisplayCitizenInfo()
    {
        Console.WriteLine("Citizen's Information:");
        Console.WriteLine("SSN: {0}", ssn);
        Console.WriteLine("Age: {0}\n", age);
    }
    public Citizen()
    {
        Console.WriteLine("Please enter the citizens Social Security number: ");
        SSN = Console.ReadLine();
        Console.WriteLine("Please enter the citizens age: ");
        Age = Console.ReadLine();
    }
}
    
public class Employee : Citizen
{
    private string name;
    private string id;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }
    public string Id
    {
        get { return id; }
        set { id = value; }
    }

    public void DisplayInfo()
    {
        Console.WriteLine("Employee's name: {0}", name);
        Console.WriteLine("Employee's id: {0}", id);
    }
}
    
class MyClass
{
    static void Main(string[] args)
    {
        // Create object:
        Employee emp = new Employee();

        // Read name and id:
        Console.Write("Please enter the employee's name: ");
        emp.Name = Console.ReadLine();

        Console.Write("Please enter the employee's id: ");
        emp.Id = Console.ReadLine();

        // Display information:
        emp.DisplayInfo();
    }
}


GeneralRe: Example 5-14 - Drill 5-3 Pin
Pete O'Hanlon23-Sep-13 1:24
mvePete O'Hanlon23-Sep-13 1:24 
GeneralRe: Example 5-14 - Drill 5-3 Pin
N8tiv23-Sep-13 1:45
N8tiv23-Sep-13 1:45 
Questionbug/challenge poll Pin
Per Söderlund22-Sep-13 20:59
Per Söderlund22-Sep-13 20:59 
AnswerRe: bug/challenge poll Pin
Richard MacCutchan22-Sep-13 21:35
mveRichard MacCutchan22-Sep-13 21:35 
GeneralRe: bug/challenge poll Pin
Per Söderlund22-Sep-13 21:40
Per Söderlund22-Sep-13 21:40 
AnswerRe: bug/challenge poll Pin
ExcellentOrg23-Sep-13 8:26
ExcellentOrg23-Sep-13 8:26 
Questionc# on my machine I have installed the virtual webcam and integrated webcam already present. So how we identify that this is virtual webcam Pin
ankur4747@yahoo.com22-Sep-13 20:04
ankur4747@yahoo.com22-Sep-13 20:04 
Questionproblem: webBrowser1.Navigate OR the loaded page? - for a jumping cursor. Pin
_Q12_22-Sep-13 7:39
_Q12_22-Sep-13 7:39 
AnswerRe: problem: webBrowser1.Navigate OR the loaded page? - for a jumping cursor. Pin
Dave Kreskowiak22-Sep-13 8:56
mveDave Kreskowiak22-Sep-13 8:56 
GeneralRe: problem: webBrowser1.Navigate OR the loaded page? - for a jumping cursor. Pin
_Q12_22-Sep-13 16:07
_Q12_22-Sep-13 16:07 
GeneralRe: problem: webBrowser1.Navigate OR the loaded page? - for a jumping cursor. Pin
_Q12_22-Sep-13 20:30
_Q12_22-Sep-13 20:30 
GeneralRe: problem: webBrowser1.Navigate OR the loaded page? - for a jumping cursor. Pin
Dave Kreskowiak23-Sep-13 1:20
mveDave Kreskowiak23-Sep-13 1:20 
QuestionC# devper in Thailand Pin
Sunsern Promsen22-Sep-13 2:16
Sunsern Promsen22-Sep-13 2:16 
AnswerRe: C# devper in Thailand Pin
OriginalGriff22-Sep-13 2:22
mveOriginalGriff22-Sep-13 2:22 
AnswerRe: C# devper in Thailand Pin
Abhinav S22-Sep-13 3:42
Abhinav S22-Sep-13 3:42 
AnswerRe: C# devper in Thailand Pin
BillWoodruff22-Sep-13 13:37
professionalBillWoodruff22-Sep-13 13:37 
GeneralRe: C# devper in Thailand Pin
Sunsern Promsen22-Sep-13 15:16
Sunsern Promsen22-Sep-13 15:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.