Click here to Skip to main content
15,914,165 members
Home / Discussions / C#
   

C#

 
AnswerRe: Removing all non-alphanumeric values Pin
S. Senthil Kumar3-Oct-05 18:30
S. Senthil Kumar3-Oct-05 18:30 
GeneralRe: Removing all non-alphanumeric values Pin
econner3-Oct-05 18:50
econner3-Oct-05 18:50 
GeneralRe: Removing all non-alphanumeric values Pin
S. Senthil Kumar3-Oct-05 19:16
S. Senthil Kumar3-Oct-05 19:16 
GeneralRe: Removing all non-alphanumeric values Pin
econner4-Oct-05 6:01
econner4-Oct-05 6:01 
QuestionSimultaneously Write to and Read from the same file Pin
CNU3-Oct-05 16:26
CNU3-Oct-05 16:26 
QuestionCopying a Reference Type? Pin
YawgmothIII3-Oct-05 14:13
YawgmothIII3-Oct-05 14:13 
AnswerRe: Copying a Reference Type? Pin
Jose Lamas Rios3-Oct-05 16:16
Jose Lamas Rios3-Oct-05 16:16 
AnswerRe: Copying a Reference Type? Pin
S. Senthil Kumar3-Oct-05 18:36
S. Senthil Kumar3-Oct-05 18:36 
YawgmothIII wrote:
Or is the only way copy a reference type is to create a new one and then move all the info out of the old one into the new

That's how you do it. However, there are many ways to do that,
1. You can use MemberwiseClone.
2. Your object can implement ICloneable, implement the Clone method and do the copying there
3. You can use a nifty trick, serialize and deserialize the object back, you'll get a new copy and .NET handles all the copying for you.
private object Copy(object original)
{
   using (MemoryStream ms = new MemoryStream())
   {
      BinaryFormatter fs = new BinaryFormatter(original.GetType());
      fs.Serialize(ms, original);
      return fs.Deserialize(ms);
   }
}


Regards
Senthil

Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
GeneralRe: Copying a Reference Type? Pin
Robert Rohde3-Oct-05 21:00
Robert Rohde3-Oct-05 21:00 
AnswerRe: Copying a Reference Type? Pin
Venkat60704-Oct-05 1:09
Venkat60704-Oct-05 1:09 
Questionsome questions... Pin
Sasuko3-Oct-05 12:11
Sasuko3-Oct-05 12:11 
AnswerRe: some questions... Pin
seee sharp3-Oct-05 17:50
seee sharp3-Oct-05 17:50 
AnswerRe: some questions... Pin
S. Senthil Kumar3-Oct-05 18:38
S. Senthil Kumar3-Oct-05 18:38 
Questionxml parsing of IIS log files Pin
Member 23270093-Oct-05 11:17
Member 23270093-Oct-05 11:17 
AnswerRe: xml parsing of IIS log files Pin
leppie3-Oct-05 20:31
leppie3-Oct-05 20:31 
GeneralRe: xml parsing of IIS log files Pin
Member 23270094-Oct-05 11:02
Member 23270094-Oct-05 11:02 
QuestionGraph vertex edge weights Pin
Gedrain3-Oct-05 10:52
Gedrain3-Oct-05 10:52 
AnswerRe: Graph vertex edge weights Pin
Mohamad Al Husseiny3-Oct-05 12:47
Mohamad Al Husseiny3-Oct-05 12:47 
GeneralRe: Graph vertex edge weights Pin
Gedrain4-Oct-05 8:26
Gedrain4-Oct-05 8:26 
QuestionWebresponse Question Pin
Steve Messer3-Oct-05 10:13
Steve Messer3-Oct-05 10:13 
GeneralRe: Webresponse Question Pin
Guffa3-Oct-05 14:19
Guffa3-Oct-05 14:19 
GeneralRe: Webresponse Question Pin
Steve Messer3-Oct-05 14:45
Steve Messer3-Oct-05 14:45 
GeneralRe: Webresponse Question Pin
seee sharp3-Oct-05 17:52
seee sharp3-Oct-05 17:52 
GeneralRe: Webresponse Question Pin
Steve Messer3-Oct-05 19:03
Steve Messer3-Oct-05 19:03 
GeneralRe: Webresponse Question Pin
Guffa3-Oct-05 23:59
Guffa3-Oct-05 23:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.