By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,919 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,919 IT Pros & Developers. It's quick & easy.

Resetting all object variables in c#

P: n/a
lee
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.
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
lee <le*@discussions.microsoft.com> wrote:
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...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

P: n/a
Why not having a Reset something method on that object, doing it for you.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
lee <le*@discussions.microsoft.com> wrote:
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...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3

P: n/a
Dennis Myrén <de****@oslokb.no> wrote:
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 :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

P: n/a
Or also just creating a new instance...

Patrice

--

"Dennis Myrén" <de****@oslokb.no> a écrit dans le message de
news:Zo********************@news4.e.nsc.no...
Why not having a Reset something method on that object, doing it for you.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
lee <le*@discussions.microsoft.com> wrote:
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...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.