473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Copy of an object.

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
2 1494
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
5
by: Tony Johansson | last post by:
Hello! I'm reading in a book about C++ and that is something that sound strange. It says "Pointers have reference-assignment semantics similar to those in Java. For example, after the...
16
by: bluekite2000 | last post by:
I want Matrix A(B) to create shallow copy of B but A=B to create deep copy of B. Is that bad design? Why and why not?
5
by: lion | last post by:
in .net, if you set annstance-A of a class equal to another instance-B, a pointer will add to B, but if i want to create a copy of B instead of pointer, how to operate? Note:serialization...
10
by: utab | last post by:
Dear all, So passing and returning a class object is the time when to include the definition of the copy constructor into the class definition. But if we don't call by value or return by value, ...
2
by: flamexx7 | last post by:
http://www.rafb.net/paste/results/V3TZeb28.html In this code, why copy constructor is not called while returning object from no_arg() . I was trying to find answer in C++ Standard. and there it's...
13
by: Jeroen | last post by:
Hi all, I'm trying to implement a certain class but I have problems regarding the copy ctor. I'll try to explain this as good as possible and show what I tried thusfar. Because it's not about a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.