|
-
December 31st, 2008, 01:42 PM
#1
[RESOLVED] Passing generic classes as arguments
I'm unsure of what exactly I'm looking for, so hopefully you'll be able to work through it with me, and someone will be able to tell me what if what I'm talking about exists in .NET.
What I'm trying to accomplish is writing a class that will accept any object along with its properties and values of those properties, and modify the object, setting the properties to those values. What I'm imagining is a method that accepts an object and a dictionary with the objects Properties as keys, and the Values those properties are set to as values. Then the code will set each property to the correct value. Another option would be to call the constructor for that object's class, and pass each property to that, then return the object.
What is important here is that I don't want to have to write a new method or class for each object I may be passing and modifying, and would rather just pass a different dictionary and object.
I don't know what that's called in .NET or C#, I looked up generics, but unless I missed something, I don't think it will be able to do what I want.
If you're interested in the implementation of this class, I'm using it to simplify accessing an SQL database in my webapp. I want to be able to have Add, Get, Modify and Delete methods, so the Modify method will be the one described above. It will accept the object and the Properties/Values, modify the existing object (or create a new one) write it to the database, and return it to the calling code.
If anyone has any code samples, or even keywords about what this technology is called in .NET, I'd be very appreciative!
Thank you!
(I'm using VS 2008 and .NET 3.5)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|