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

Copy of an object.

P: n/a
I would like to make a copy of the Request.Form collection object. A
shallow copy is fine. Request.Form is read-only and I'd like a copy to work
with. It seems MemberwiseClone() is protected. I'd be very appreciative if
someone would point me in he right direction.

Thank you,
Andrew
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
NameValueCollection source = Request.Form;
NameValueCollection dest = new NameValueCollection();

foreach(string sKey in source.Keys)
dest.Add(sKey, source[sKey]);
"Andrew" <an*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I would like to make a copy of the Request.Form collection object. A
shallow copy is fine. Request.Form is read-only and I'd like a copy to
work with. It seems MemberwiseClone() is protected. I'd be very
appreciative if someone would point me in he right direction.

Thank you,
Andrew

Nov 17 '05 #2

P: n/a
Thanks for such a quick response Adam. That is certainly a simple and
workable solution. Since you've answered my question the following is
purely academic, maybe you can shed some light. Can a shallow/deep copy be
made of a .net object? Not a copy of my own object but a copy an object
provided by the .net run-time, such as asp.net's response object.

Thanks again for the help.
"Adam Barker" <adam@NO******@q-state.co.NO_SPAM.uk> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
NameValueCollection source = Request.Form;
NameValueCollection dest = new NameValueCollection();

foreach(string sKey in source.Keys)
dest.Add(sKey, source[sKey]);
"Andrew" <an*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I would like to make a copy of the Request.Form collection object. A
shallow copy is fine. Request.Form is read-only and I'd like a copy to
work with. It seems MemberwiseClone() is protected. I'd be very
appreciative if someone would point me in he right direction.

Thank you,
Andrew


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.