OpCodes to set private properties
Hi,
I'm new to using Reflection.Emit and I'm trying to create a class that will have the following setup:
public class Test
{
private Guid _id;
public Test()
{
_id=Guid.NewGuid();
}
}
I managed to define the class and have a default constructor that does nothing, however I'm stuck on creating a new Guid within the constructor and assigning it to the private property _id.
Any help would be greately appreciated.
Regards,
Jo

Sam HobbsRank #107 · 20.5K reputationPosted Dec 3, 2009, 8:55 AM EST
Jo Palac5 reputationPosted Dec 3, 2009, 3:24 PM EST
Sam HobbsRank #107 · 20.5K reputationPosted Dec 3, 2009, 4:48 PM EST
I used your code in the following program and it works; at least it does what I expect it to. I admit that I know nothing about Reflection.Emit. My guess is that there is something you are expecting to be more difficult than it really is.
Jo Palac5 reputationPosted Dec 3, 2009, 5:51 PM EST
Sam HobbsRank #107 · 20.5K reputationPosted Dec 3, 2009, 9:28 PM EST