Resetting all object variables in c#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wont to reset all the variables in a c# object at run time, I was hoping
for a field collection or some similar method of iterating through the
variables.

Any ideas ???
 
lee said:
I wont to reset all the variables in a c# object at run time, I was hoping
for a field collection or some similar method of iterating through the
variables.

Any ideas ???

Well, you could use reflection. It won't be terribly fast though...
 
Why not having a Reset something method on that object, doing it for you.
 
Dennis Myrén said:
Why not having a Reset something method on that object, doing it for you.

Yes, that's certainly the better bet if you are in control of the type.
Of course it means you've got to modify the method every time you add a
field, too. I was assuming that the OP didn't want to do that for
whatever reason, but I think they'd have to be pretty good reasons :)
 
Or also just creating a new instance...

Patrice

--

Dennis Myrén said:
Why not having a Reset something method on that object, doing it for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top