I'm looking for a Best Practice to set a Object's properties to the constructors' parameters which have the same name. so basically my code looks the following:
public class Person
    {
        //Properties
        public string firstname;
        public string lastname;
        public string nickname;
        ...
        //Constructor
        public Person(string firstname, string lastname, string nickname, ...) {
            this.fistname = firstname;
            this.lastname = lastname;
            this.nickname = nickname;
            ...
        }
}
this is quite a common task which you encounter a lot. shoudln't there be a better way to deal with this? is there a "Best Practice" to achieve the same?
I was thinking of something like this:
public class Person
    {
        //Properties
        public string firstname;
        public string lastname;
        public string nickname;
        ...
        //Constructor
        public Person(string firstname, string lastname, string nickname, ...) {
            foreach (PropertyInfo prop in typeof(Person).GetProperties())
            {
                this.prop = prop.Name; //something like this possible?
            }
        }
}
the prop.Name would have to be kinda preprocessed and than used as the same-named variable. if i get more properties this will save alot of code i think .. thanks in advance!
phil
