Click here to Skip to main content
15,919,121 members
Home / Discussions / C#
   

C#

 
Questionhow to get XML tag of different sites for use in our sites for news reading Pin
v.k.s21-Nov-05 18:30
v.k.s21-Nov-05 18:30 
QuestionReading Active Directory user password? Pin
devvvy21-Nov-05 16:01
devvvy21-Nov-05 16:01 
AnswerRe: Reading Active Directory user password? Pin
mav.northwind21-Nov-05 20:29
mav.northwind21-Nov-05 20:29 
GeneralRe: Reading Active Directory user password? Pin
devvvy21-Nov-05 20:35
devvvy21-Nov-05 20:35 
GeneralRe: Reading Active Directory user password? Pin
mav.northwind21-Nov-05 21:32
mav.northwind21-Nov-05 21:32 
GeneralRe: Reading Active Directory user password? Pin
devvvy21-Nov-05 21:43
devvvy21-Nov-05 21:43 
QuestionConfused about shallow and deep copy in C# Pin
Johny Ng21-Nov-05 13:00
Johny Ng21-Nov-05 13:00 
AnswerRe: Confused about shallow and deep copy in C# Pin
Joshua Quick21-Nov-05 14:14
Joshua Quick21-Nov-05 14:14 
First, you need to understand the difference between value types and reference types.

All structures and primitives (such as int, long, float) are value types. Value types exist in the stack and are always copied. For example:
int a = 1; // Set a to 1.<br />
int b = a; // Copy a's value to b.


All classes are reference types and their objects exist in the heap. Variables used to access class objects really only store addresses (so to speak) to their objects. Keyword "new" creates an object and returns a reference to that object. For example:
ArrayList a = new ArrayList(); // 'a' refers to new ArrayList object.<br />
ArrayList b = a; // b copies a's reference, but refers to same object.


Now, a shallow copy means that only an object's member variables are copied. This means the value types and references are copied, but the referenced objects themselves are not copied/cloned. A deep copy is when you clone the referenced objects too. You can do this by overriding your class' Clone() method and explicitly clone your reference member variables.

In the case of your ArrayList example, it's storing integers which are value types. So, changing the cloned ArrayList's items will not effect the original ArrayList. However, if the original ArrayList stored reference types instead, then that would be another story.

Phew! That was a bit long winded, but I hope that made sense.
AnswerRe: Confused about shallow and deep copy in C# Pin
ABC_Developer21-Nov-05 18:26
ABC_Developer21-Nov-05 18:26 
Question[very urgent]!! combobox question Pin
Sam 200621-Nov-05 12:26
Sam 200621-Nov-05 12:26 
AnswerRe: [very urgent]!! combobox question Pin
enjoycrack21-Nov-05 12:48
enjoycrack21-Nov-05 12:48 
AnswerRe: [very urgent]!! combobox question Pin
cshaaaa21-Nov-05 19:09
cshaaaa21-Nov-05 19:09 
Questionbarcode: code 128 from c# Pin
grahamcere21-Nov-05 12:02
grahamcere21-Nov-05 12:02 
AnswerRe: barcode: code 128 from c# Pin
Christian Graus21-Nov-05 14:53
protectorChristian Graus21-Nov-05 14:53 
GeneralRe: barcode: code 128 from c# Pin
grahamcere22-Nov-05 5:15
grahamcere22-Nov-05 5:15 
QuestionHow to display a pdf file in a aspx form Pin
Aricardo21-Nov-05 12:00
Aricardo21-Nov-05 12:00 
AnswerRe: How to display a pdf file in a aspx form Pin
enjoycrack21-Nov-05 12:42
enjoycrack21-Nov-05 12:42 
QuestionEasiest way to parse a data packet Pin
Tom Wright21-Nov-05 11:26
Tom Wright21-Nov-05 11:26 
AnswerRe: Easiest way to parse a data packet Pin
KaptinKrunch21-Nov-05 13:41
KaptinKrunch21-Nov-05 13:41 
GeneralRe: Easiest way to parse a data packet Pin
Tom Wright22-Nov-05 6:10
Tom Wright22-Nov-05 6:10 
GeneralRe: Easiest way to parse a data packet Pin
KaptinKrunch23-Nov-05 6:53
KaptinKrunch23-Nov-05 6:53 
QuestionI have string[] names = {&quot;name1&quot;, &quot;name2&quot;} ... Pin
Anthony Mushrow21-Nov-05 10:58
professionalAnthony Mushrow21-Nov-05 10:58 
AnswerRe: I have string[] names = {&amp;quot;name1&amp;quot;, &amp;quot;name2&amp;quot;} ... Pin
enjoycrack21-Nov-05 12:37
enjoycrack21-Nov-05 12:37 
AnswerRe: I have string[] names = {&amp;quot;name1&amp;quot;, &amp;quot;name2&amp;quot;} ... Pin
André Ziegler21-Nov-05 12:39
André Ziegler21-Nov-05 12:39 
QuestionUnmanaged Thread Unsafe Library Pin
BenjaminWalker21-Nov-05 10:49
BenjaminWalker21-Nov-05 10:49 

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.