Click here to Skip to main content
15,917,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: Copy an instance Pin
sjembek31-Jul-06 6:42
sjembek31-Jul-06 6:42 
AnswerRe: Copy an instance Pin
A.A.31-Jul-06 4:45
A.A.31-Jul-06 4:45 
GeneralRe: Copy an instance Pin
sjembek31-Jul-06 5:35
sjembek31-Jul-06 5:35 
AnswerRe: Copy an instance Pin
LongRange.Shooter31-Jul-06 5:12
LongRange.Shooter31-Jul-06 5:12 
AnswerRe: Copy an instance Pin
Judah Gabriel Himango31-Jul-06 5:29
sponsorJudah Gabriel Himango31-Jul-06 5:29 
GeneralRe: Copy an instance Pin
sjembek31-Jul-06 5:52
sjembek31-Jul-06 5:52 
GeneralRe: Copy an instance Pin
sjembek31-Jul-06 6:43
sjembek31-Jul-06 6:43 
AnswerRe: Copy an instance Pin
Libor Tinka31-Jul-06 12:44
Libor Tinka31-Jul-06 12:44 
I'm doing this using the Clone method of the object. I think there's no universal mechanism for copying objects, so you need to implement this method by your own. If you are working with more types, it is good to use some ICloneable interface.

This is an example:

<br />
public interface ICloneable {<br />
<br />
  object Clone();<br />
}<br />
<br />
public class BitmapWithArray : ICloneable {<br />
<br />
  public Bitmap bitmap = null;<br />
  public int[] array = null;<br />
  public ushort someValue = 0;<br />
<br />
  public object Clone() {<br />
<br />
    BitmapWithArray obj = new BitmapWithArray();<br />
<br />
    if (this.bitmap != null)<br />
      obj.bitmap = (Bitmap)this.bitmap.Clone();<br />
<br />
    if (this.array != null)<br />
      obj.array = (int[])this.array.Clone();<br />
<br />
    obj.someValue = this.someValue; // this is a value type, no copies needed<br />
  }<br />
}<br />

QuestionRichtext box Ctrl + I Pin
AB777131-Jul-06 3:32
AB777131-Jul-06 3:32 
AnswerRe: Richtext box Ctrl + I Pin
LongRange.Shooter31-Jul-06 4:59
LongRange.Shooter31-Jul-06 4:59 
GeneralRe: Richtext box Ctrl + I Pin
AB777131-Jul-06 17:54
AB777131-Jul-06 17:54 
GeneralRe: Richtext box Ctrl + I Pin
LongRange.Shooter1-Aug-06 8:48
LongRange.Shooter1-Aug-06 8:48 
GeneralRe: Richtext box Ctrl + I Pin
AB77711-Aug-06 18:31
AB77711-Aug-06 18:31 
GeneralRe: Richtext box Ctrl + I Pin
LongRange.Shooter2-Aug-06 12:35
LongRange.Shooter2-Aug-06 12:35 
GeneralRe: Richtext box Ctrl + I Pin
AB77712-Aug-06 17:53
AB77712-Aug-06 17:53 
QuestionProduct Registration and Keys Pin
saamirp31-Jul-06 2:48
saamirp31-Jul-06 2:48 
AnswerRe: Product Registration and Keys Pin
gnjunge31-Jul-06 3:03
gnjunge31-Jul-06 3:03 
AnswerRe: Product Registration and Keys Pin
AB777131-Jul-06 3:20
AB777131-Jul-06 3:20 
GeneralRe: Product Registration and Keys Pin
gnjunge31-Jul-06 4:18
gnjunge31-Jul-06 4:18 
GeneralRe: Product Registration and Keys Pin
AB777131-Jul-06 4:26
AB777131-Jul-06 4:26 
AnswerRe: Product Registration and Keys Pin
Ennis Ray Lynch, Jr.31-Jul-06 4:33
Ennis Ray Lynch, Jr.31-Jul-06 4:33 
AnswerRe: Product Registration and Keys Pin
LongRange.Shooter31-Jul-06 5:16
LongRange.Shooter31-Jul-06 5:16 
AnswerRe: Product Registration and Keys Pin
Steve Maier31-Jul-06 7:32
professionalSteve Maier31-Jul-06 7:32 
QuestionInstaller Dilemma!! Pin
Willem_Le_Roux31-Jul-06 2:26
Willem_Le_Roux31-Jul-06 2:26 
AnswerRe: Installer Dilemma!! Pin
LongRange.Shooter31-Jul-06 5:17
LongRange.Shooter31-Jul-06 5:17 

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.