troubleshooting Question

Dynamic Generic Data Transfer Object

Avatar of Meps
MepsFlag for United States of America asked on
ASP.NETC#Visual Basic.NET
5 Comments2 Solutions428 ViewsLast Modified:
This has to already exist, but I just can't find it, or don't understand what I am looking at.

Simplely put I want to do this.  I want to have an object that I can use that would be generic, but dynamic at the same time.

The code snippet shows something like what I want to do.  I want to create an object, tell it why datatypes I am going to use along with the names of the properties I want, and then be able to fill out the object with the values I want.  So I can pass it along through the application.

So how would I create this generic DTO?
GenDTO bob = new GenDTO();

bob.add(datetime "StartDate");
bob.add(string "Name");

bob.StartDate = '1/1/2010';
bob.Name = 'Smith';

GenDTO g123 = new GenDTO();
g123.add(int "ID");
g123.add(bool "Terminated");

g123.ID = 2;
g123.Terminated = true;
Kusala Wijayasena
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros