Click here to Skip to main content
15,894,630 members
Home / Discussions / C#
   

C#

 
GeneralRe: Is this good code practice? Pin
venomation30-Apr-10 13:54
venomation30-Apr-10 13:54 
AnswerRe: Is this good code practice? Pin
AspDotNetDev30-Apr-10 14:39
protectorAspDotNetDev30-Apr-10 14:39 
AnswerRe: Is this good code practice? Pin
Abhinav S30-Apr-10 16:21
Abhinav S30-Apr-10 16:21 
AnswerRe: Is this good code practice? Pin
Som Shekhar30-Apr-10 19:41
Som Shekhar30-Apr-10 19:41 
AnswerRe: Is this good code practice? Pin
Pete O'Hanlon30-Apr-10 20:46
mvePete O'Hanlon30-Apr-10 20:46 
GeneralRe: Is this good code practice? Pin
venomation1-May-10 4:15
venomation1-May-10 4:15 
GeneralRe: Is this good code practice? Pin
PIEBALDconsult1-May-10 5:41
mvePIEBALDconsult1-May-10 5:41 
GeneralRe: Is this good code practice? Pin
venomation1-May-10 7:18
venomation1-May-10 7:18 
That is an awesome answer thank you for that ! Big Grin | :-D

I was not completely sure of what the exercise meant but I gave it a try:

class Person
{
    private string _forName;
    private string _surName;
    private string _title;

    public Person(string forname, string surname, string title)
    {
        ForName = forname;
        SurName = surname;
        Title = title;
    }

    public string ForName
    {
        get { return _forName; }
        set { _forName = value; }
    }

    public string SurName
    {
        get { return _surName; }
        set { _surName = value; }
    }

    public string Title
    {
        get { return _title; }
        set { _title = value; }
    }

    public override string ToString()
    {
        string fullName = string.Format("{0} {1} {2}", ForName, SurName,Title);
        return fullName; ;
    }

}

class PersonManager
{
    private List<Person> _personList;

    public PersonManager()
    {
        _personList = new List<Person>(10);
        //add a few people as a test
        _personList.Add(new Person("James", "x", "Prog"));
        _personList.Add(new Person("Claire", "y", "Illu"));
    }

    public void DumpAllToConsole()
    {
        //Prints the details of every person
        foreach (Person p in _personList)
        {
            Console.WriteLine(p.ToString());
        }
    }
}


class Program
{
    delegate void DictionaryDel();
    static DictionaryDel _invokeAction;
    static Dictionary<PersonManager, DictionaryDel> _action;
    static PersonManager _personManager;

    static void Main()
    {
        _action = new Dictionary<PersonManager, DictionaryDel>();
        _personManager = new PersonManager();

        _invokeAction += _personManager.DumpAllToConsole;

        _action.Add(_personManager, _invokeAction);

        _action[_personManager]();


        Console.Read();

    }
}

?
GeneralRe: Is this good code practice? Pin
PIEBALDconsult1-May-10 19:41
mvePIEBALDconsult1-May-10 19:41 
GeneralRe: Is this good code practice? [modified] Pin
venomation2-May-10 1:49
venomation2-May-10 1:49 
GeneralRe: Is this good code practice? Pin
PIEBALDconsult2-May-10 4:07
mvePIEBALDconsult2-May-10 4:07 
GeneralRe: Is this good code practice? [modified] Pin
venomation2-May-10 5:58
venomation2-May-10 5:58 
GeneralRe: Is this good code practice? Pin
PIEBALDconsult2-May-10 10:24
mvePIEBALDconsult2-May-10 10:24 
GeneralRe: Is this good code practice? Pin
venomation2-May-10 11:41
venomation2-May-10 11:41 
GeneralRe: Is this good code practice? Pin
PIEBALDconsult2-May-10 17:44
mvePIEBALDconsult2-May-10 17:44 
AnswerRe: Is this good code practice? Pin
venomation3-May-10 0:56
venomation3-May-10 0:56 
GeneralRe: Is this good code practice? Pin
PIEBALDconsult3-May-10 3:59
mvePIEBALDconsult3-May-10 3:59 
GeneralRe: Is this good code practice? Pin
Alaric_3-May-10 4:45
professionalAlaric_3-May-10 4:45 
GeneralRe: Is this good code practice? Pin
venomation3-May-10 5:04
venomation3-May-10 5:04 
QuestionCreate Image in WinForms vs Asp.net Pin
#realJSOP30-Apr-10 9:44
mve#realJSOP30-Apr-10 9:44 
AnswerRe: Create Image in WinForms vs Asp.net Pin
Luc Pattyn30-Apr-10 10:04
sitebuilderLuc Pattyn30-Apr-10 10:04 
GeneralRe: Create Image in WinForms vs Asp.net Pin
#realJSOP30-Apr-10 11:35
mve#realJSOP30-Apr-10 11:35 
GeneralRe: Create Image in WinForms vs Asp.net Pin
Luc Pattyn30-Apr-10 11:41
sitebuilderLuc Pattyn30-Apr-10 11:41 
GeneralRe: Create Image in WinForms vs Asp.net Pin
#realJSOP30-Apr-10 12:04
mve#realJSOP30-Apr-10 12:04 
GeneralRe: Create Image in WinForms vs Asp.net Pin
Luc Pattyn30-Apr-10 12:30
sitebuilderLuc Pattyn30-Apr-10 12:30 

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.