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 HobbsPosted Dec 4, 2009, 2:28 AM
Jo PalacPosted Dec 3, 2009, 10:51 PM
Sam HobbsPosted Dec 3, 2009, 9:48 PM
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 PalacPosted Dec 3, 2009, 8:24 PM
Sam HobbsPosted Dec 3, 2009, 1:55 PM