K
kbin
Hi all,
I'm wondering if it is possible to have some sort of soft reference to
an object's properties by using a string representing the property
name. Let me explain by an example, here is my class:
public class thing {
public string model {
get; set;
}
public string make {
get; set;
}
}
And then I want to do something like the following:
thing k = new thing();
string propname = "model";
k[propname] = "Model name KS445";
k["make"] = "Maker Ltd.";
In JavaScript this is possible by using the above syntax, and in perl,
most objects are Hashes where all properties are available using the
$object->{'propname'} syntax, but is there some sort of mechanism in
csharp to do the same thing?
--Kalle
I'm wondering if it is possible to have some sort of soft reference to
an object's properties by using a string representing the property
name. Let me explain by an example, here is my class:
public class thing {
public string model {
get; set;
}
public string make {
get; set;
}
}
And then I want to do something like the following:
thing k = new thing();
string propname = "model";
k[propname] = "Model name KS445";
k["make"] = "Maker Ltd.";
In JavaScript this is possible by using the above syntax, and in perl,
most objects are Hashes where all properties are available using the
$object->{'propname'} syntax, but is there some sort of mechanism in
csharp to do the same thing?
--Kalle