Click here to Skip to main content
15,916,288 members
Home / Discussions / C#
   

C#

 
AnswerRe: NetworkStream.Write [modified] Pin
Luc Pattyn11-Jan-09 12:48
sitebuilderLuc Pattyn11-Jan-09 12:48 
GeneralRe: NetworkStream.Write Pin
Ben Fair12-Jan-09 7:43
Ben Fair12-Jan-09 7:43 
QuestionObject type not known at Design TIme Pin
CodingYoshi11-Jan-09 10:00
CodingYoshi11-Jan-09 10:00 
AnswerRe: Object type not known at Design TIme Pin
User 665811-Jan-09 10:46
User 665811-Jan-09 10:46 
AnswerRe: Object type not known at Design TIme Pin
Not Active11-Jan-09 12:31
mentorNot Active11-Jan-09 12:31 
GeneralRe: Object type not known at Design TIme Pin
CodingYoshi11-Jan-09 12:38
CodingYoshi11-Jan-09 12:38 
GeneralRe: Object type not known at Design TIme Pin
Guffa11-Jan-09 20:05
Guffa11-Jan-09 20:05 
AnswerRe: Object type not known at Design TIme Pin
Guffa11-Jan-09 20:02
Guffa11-Jan-09 20:02 
This could be done using reflection, but I would not recommend it as it adds a lot of overhead.

I would rather make the class responsible for assigning the values, using an interface like:
public interface IDynamicProperties {
   string[] GetPropertyNames { get; }
   void SetProperty(string name, object value);
}

The class to be populated could implement it like this:
public Customer : IDynamicProperties {

   public int Id { get; private set; }
   public string FirstName { get; private set; }
   public string LastName { get; private set; }

   public string[] GetPropertyNames{ get { return { "CustomerId", "FirstName", "LastName" } } }

   public void SetProperty(string name, object value) {
      switch (name) {
         case "CustomerID": Id = (int)value; break;
         case "FirstName": FirstName = (string)value; break;
         case "LastName": LastName = (string)value; break;
      }
   }

}


Despite everything, the person most likely to be fooling you next is yourself.

QuestionHow do I write to this class? [modified] Pin
e40s11-Jan-09 8:17
e40s11-Jan-09 8:17 
AnswerRe: How do I write to this class? Pin
Not Active11-Jan-09 8:28
mentorNot Active11-Jan-09 8:28 
GeneralRe: How do I write to this class? [modified] Pin
e40s11-Jan-09 9:17
e40s11-Jan-09 9:17 
GeneralRe: How do I write to this class? Pin
Not Active11-Jan-09 9:32
mentorNot Active11-Jan-09 9:32 
GeneralRe: How do I write to this class? [modified] Pin
e40s11-Jan-09 10:02
e40s11-Jan-09 10:02 
GeneralRe: How do I write to this class? Pin
Not Active11-Jan-09 12:20
mentorNot Active11-Jan-09 12:20 
GeneralRe: How do I write to this class? [modified] Pin
e40s11-Jan-09 16:16
e40s11-Jan-09 16:16 
GeneralRe: How do I write to this class? Pin
Not Active11-Jan-09 16:29
mentorNot Active11-Jan-09 16:29 
AnswerRe: How do I write to this class? [modified] Pin
Luc Pattyn11-Jan-09 16:54
sitebuilderLuc Pattyn11-Jan-09 16:54 
AnswerRe: How do I write to this class? Pin
Pete O'Hanlon11-Jan-09 8:43
mvePete O'Hanlon11-Jan-09 8:43 
GeneralRe: How do I write to this class? Pin
e40s11-Jan-09 9:23
e40s11-Jan-09 9:23 
GeneralRe: How do I write to this class? Pin
Not Active11-Jan-09 9:29
mentorNot Active11-Jan-09 9:29 
QuestionPassword protect information in an application Pin
Karmendra Suthar11-Jan-09 7:06
Karmendra Suthar11-Jan-09 7:06 
AnswerRe: Password protect information in an application Pin
Not Active11-Jan-09 8:30
mentorNot Active11-Jan-09 8:30 
QuestionHelp Creating Sql Class Pin
Calferreira11-Jan-09 7:06
Calferreira11-Jan-09 7:06 
AnswerRe: Help Creating Sql Class Pin
User 665811-Jan-09 7:41
User 665811-Jan-09 7:41 
GeneralRe: Help Creating Sql Class Pin
Calferreira11-Jan-09 8:09
Calferreira11-Jan-09 8:09 

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.