Click here to Skip to main content
   

C#

 
AnswerRe: Textbox help! PinmemberMycroft Holmes21-Nov-12 13:01 
QuestionSpecialized List Sorting question PinmemberNuclearMan8521-Nov-12 8:12 
AnswerRe: Specialized List Sorting question [modified] PinmemberRichard Deeming21-Nov-12 9:03 
AnswerRe: Specialized List Sorting question PinmemberSledgeHammer0121-Nov-12 9:06 
AnswerRe: Specialized List Sorting question PinmemberRichard Deeming21-Nov-12 9:32 
AnswerRe: Specialized List Sorting question [modified] PinmemberPIEBALDconsult21-Nov-12 9:57 
AnswerRe: Specialized List Sorting question PinmemberBobJanova21-Nov-12 23:50 
QuestionWinForms Class Design PinmemberMember 961929521-Nov-12 7:43 
Hi,
I am learning OOP and trying to apply it to my C# WinForms applications.
So I have a Form with 2 textboxes. One to enter professor. Another to enter lecturer.
 
I have created an abstract 'Staff' class. Then I have a Professor class and a Lecturer class. Both inherit from Staff.
In Staff, I have declared an abstract property StaffName. So this must be implemented in other classes. Am I correct so far?
 
These classes are called on Button_Click event...
Professor professor = new Professor();
            professor.StaffName = staffTextBox1.Text;
 
            Lecturer lecturer = new Lecturer();
            lecturer.StaffName = staffTextBox2.Text;
 
            MessageBox.Show(string.Format("Analyst {0}\nSupervisor {1}", professor.StaffName, lecturer.StaffName), "Output", MessageBoxButtons.OK);
 
And my classes...
 
    public abstract class Staff
    {
        protected string staffName;
        public abstract string StaffName
        {
            get;
            set;
        }
    }
 
    public class Professor : Staff
    {
        public override string StaffName
        {
            get
            {
                return staffName;
            }
            set
            {
                staffName = value;
            }
        }
    }
 
    public class Lecturer : Staff
    {
        public override string StaffName
        {
            get
            {
                return staffName;
            }
            set
            {
                staffName = value;
            }
        }
    }
 
Is this a correct OOP technique in WinForms or is there issues with my code design?
 
Thanks for your help!!
AnswerRe: WinForms Class Design PinmvpRichard MacCutchan21-Nov-12 8:15 
GeneralRe: WinForms Class Design PinmemberMatt U.21-Nov-12 9:16 
GeneralRe: WinForms Class Design PinmvpRichard MacCutchan21-Nov-12 9:56 
GeneralRe: WinForms Class Design PinmemberMatt U.21-Nov-12 9:59 
GeneralRe: WinForms Class Design PinmvpRichard MacCutchan21-Nov-12 10:06 
GeneralRe: WinForms Class Design PinmemberMatt U.21-Nov-12 10:21 
GeneralRe: WinForms Class Design PinmemberPIEBALDconsult21-Nov-12 11:27 
AnswerRe: WinForms Class Design PinmemberPIEBALDconsult21-Nov-12 10:07 
QuestionUplaod Article To Codeproject PingroupkatlegoEmmnanuelNkosi21-Nov-12 4:44 
AnswerRe: Uplaod Article To Codeproject PinmemberPIEBALDconsult21-Nov-12 4:48 
AnswerRe: Uplaod Article To Codeproject PinmvpRichard MacCutchan21-Nov-12 5:34 
QuestionPrint Crystal Report in c# Using Access Database? Pinmemberkashifjaat21-Nov-12 3:09 
QuestionGenerate Morse Code Sound Pinmemberlong dao21-Nov-12 2:24 
AnswerRe: Generate Morse Code Sound PinprotectorPete O'Hanlon21-Nov-12 2:45 
GeneralRe: Generate Morse Code Sound Pinmemberlong dao21-Nov-12 2:54 
GeneralRe: Generate Morse Code Sound PinprotectorPete O'Hanlon21-Nov-12 3:05 
QuestionKeeps returning NullReferenceException [modified] PinmemberMacUseless21-Nov-12 0:08 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.150129.1 | Last Updated 1 Feb 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid