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

C#

 
GeneralRe: writing combo box items Pin
Vikram A Punathambekar16-Jul-07 21:41
Vikram A Punathambekar16-Jul-07 21:41 
QuestionDrawing Digital Signal Pin
satsumatable16-Jul-07 18:52
satsumatable16-Jul-07 18:52 
AnswerRe: Drawing Digital Signal Pin
ekynox16-Jul-07 22:41
ekynox16-Jul-07 22:41 
AnswerRe: Drawing Digital Signal Pin
Bert delaVega17-Jul-07 6:24
Bert delaVega17-Jul-07 6:24 
QuestionCopying objects by value Pin
jozsurf16-Jul-07 17:59
jozsurf16-Jul-07 17:59 
AnswerRe: Copying objects by value Pin
originSH16-Jul-07 22:09
originSH16-Jul-07 22:09 
AnswerRe: Copying objects by value Pin
Luc Pattyn16-Jul-07 22:47
sitebuilderLuc Pattyn16-Jul-07 22:47 
GeneralRe: Copying objects by value Pin
jozsurf16-Jul-07 23:42
jozsurf16-Jul-07 23:42 
Thanks both for your replies. Apologies for being unclear, as my class consists only of primitive/value types (i.e. bools, structs), I only need to do a shallow copy (I suppose a deep copy could be implemented by some form of reflection?).

The following snippet of code is what I'm trying to do:

<br />
<br />
public class SimpleClass<br />
{<br />
   // default constructor<br />
   public SimpleClass ()<br />
   {<br />
      a = false;<br />
      b = 0;<br />
   }<br />
   // copy constructor (is this an incorrect term to use in C#?)<br />
   public SimpleClass (SimpleClass s)<br />
   {<br />
      a = s.a;<br />
      b = s.b;<br />
   }<br />
   // copy function<br />
   public Copy (SimpleClass s)<br />
   {<br />
      a = s.a;<br />
      b = s.b;<br />
   }<br />
   public bool a;<br />
   public int b;<br />
}<br />
<br />


and so my original question was: is there a performance difference between doing

<br />
SimpleClass a = new SimpleClass();<br />
foreach (SimpleClass y in ListOfSimpleClasses)<br />
    x.Copy(y); <br />


and

<br />
SimpleClass a = new SimpleClass();<br />
foreach (SimpleClass y in ListOfSimpleClasses)<br />
   a = new SimpleClass(y);<br />


Hope this is a little clearer.

cheers!
GeneralRe: Copying objects by value Pin
Luc Pattyn17-Jul-07 0:20
sitebuilderLuc Pattyn17-Jul-07 0:20 
GeneralRe: Copying objects by value Pin
jozsurf17-Jul-07 15:06
jozsurf17-Jul-07 15:06 
GeneralRe: Copying objects by value Pin
Luc Pattyn17-Jul-07 16:45
sitebuilderLuc Pattyn17-Jul-07 16:45 
GeneralRe: Copying objects by value Pin
jozsurf17-Jul-07 16:59
jozsurf17-Jul-07 16:59 
GeneralRe: Copying objects by value [modified] Pin
Luc Pattyn17-Jul-07 17:15
sitebuilderLuc Pattyn17-Jul-07 17:15 
GeneralRe: Copying objects by value Pin
jozsurf17-Jul-07 18:07
jozsurf17-Jul-07 18:07 
GeneralRe: Copying objects by value Pin
Luc Pattyn22-Jul-07 12:00
sitebuilderLuc Pattyn22-Jul-07 12:00 
QuestionHow to set and get Windows Application's Version? Pin
Khoramdin16-Jul-07 17:21
Khoramdin16-Jul-07 17:21 
AnswerRe: How to set and get Windows Application's Version? Pin
Vikram A Punathambekar16-Jul-07 17:40
Vikram A Punathambekar16-Jul-07 17:40 
QuestionRe: How to set and get Windows Application's Version? Pin
Khoramdin16-Jul-07 19:20
Khoramdin16-Jul-07 19:20 
AnswerRe: How to set and get Windows Application's Version? Pin
Vikram A Punathambekar16-Jul-07 21:05
Vikram A Punathambekar16-Jul-07 21:05 
AnswerRe: How to set and get Windows Application's Version? Pin
originSH16-Jul-07 22:14
originSH16-Jul-07 22:14 
AnswerRe: How to set and get Windows Application's Version? Pin
ekynox17-Jul-07 13:33
ekynox17-Jul-07 13:33 
QuestionDataGrid date AND time Column[modified] Pin
swjam16-Jul-07 14:24
swjam16-Jul-07 14:24 
AnswerRe: DataGrid date AND time Column[modified] Pin
Michael Sync16-Jul-07 17:39
Michael Sync16-Jul-07 17:39 
GeneralRe: DataGrid date AND time Column[modified] Pin
swjam16-Jul-07 20:59
swjam16-Jul-07 20:59 
GeneralRe: DataGrid date AND time Column[modified] Pin
Rhys Gravell16-Jul-07 23:09
professionalRhys Gravell16-Jul-07 23:09 

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.