Click here to Skip to main content
15,925,602 members
Home / Discussions / C#
   

C#

 
QuestionInvalid argument error ? Pin
kk.tvm25-Aug-08 1:36
kk.tvm25-Aug-08 1:36 
AnswerRe: Invalid argument error ? Pin
lisan_al_ghaib25-Aug-08 1:43
lisan_al_ghaib25-Aug-08 1:43 
AnswerRe: Invalid argument error ? Pin
N a v a n e e t h25-Aug-08 1:55
N a v a n e e t h25-Aug-08 1:55 
AnswerRe: Invalid argument error ? Pin
Guffa25-Aug-08 3:35
Guffa25-Aug-08 3:35 
GeneralRe: Invalid argument error ? Pin
chaiguy133725-Aug-08 15:11
chaiguy133725-Aug-08 15:11 
GeneralRe: Invalid argument error ? Pin
Guffa26-Aug-08 8:43
Guffa26-Aug-08 8:43 
GeneralRe: Invalid argument error ? Pin
chaiguy133726-Aug-08 8:51
chaiguy133726-Aug-08 8:51 
GeneralRe: Invalid argument error ? Pin
Guffa26-Aug-08 13:47
Guffa26-Aug-08 13:47 
GeneralRe: Invalid argument error ? Pin
chaiguy133726-Aug-08 14:57
chaiguy133726-Aug-08 14:57 
Questionstring and array are immutable? Pin
George_George24-Aug-08 23:50
George_George24-Aug-08 23:50 
AnswerRe: string and array are immutable? Pin
N a v a n e e t h25-Aug-08 0:13
N a v a n e e t h25-Aug-08 0:13 
GeneralRe: string and array are immutable? Pin
George_George25-Aug-08 0:17
George_George25-Aug-08 0:17 
GeneralRe: string and array are immutable? Pin
N a v a n e e t h25-Aug-08 0:21
N a v a n e e t h25-Aug-08 0:21 
GeneralRe: string and array are immutable? Pin
George_George25-Aug-08 1:31
George_George25-Aug-08 1:31 
AnswerRe: string and array are immutable? [Modified] Pin
Mustafa Ismail Mustafa25-Aug-08 0:20
Mustafa Ismail Mustafa25-Aug-08 0:20 
GeneralRe: string and array are immutable? [Modified] Pin
George_George25-Aug-08 1:28
George_George25-Aug-08 1:28 
GeneralRe: string and array are immutable? [Modified] Pin
N a v a n e e t h25-Aug-08 1:35
N a v a n e e t h25-Aug-08 1:35 
GeneralRe: string and array are immutable? [Modified] Pin
George_George25-Aug-08 1:39
George_George25-Aug-08 1:39 
GeneralRe: string and array are immutable? [Modified] Pin
N a v a n e e t h25-Aug-08 1:30
N a v a n e e t h25-Aug-08 1:30 
GeneralRe: string and array are immutable? [Modified] Pin
George_George25-Aug-08 1:33
George_George25-Aug-08 1:33 
GeneralRe: string and array are immutable? [Modified] Pin
N a v a n e e t h25-Aug-08 1:39
N a v a n e e t h25-Aug-08 1:39 
GeneralRe: string and array are immutable? [Modified] Pin
George_George25-Aug-08 1:42
George_George25-Aug-08 1:42 
GeneralRe: string and array are immutable? [Modified] Pin
Mustafa Ismail Mustafa25-Aug-08 2:44
Mustafa Ismail Mustafa25-Aug-08 2:44 
N a v a n e e t h wrote:
I doubt this. Array is a block of data with some length and provides indexer to access the data. This is correct for strings. But AFAIK, strings are stored as inline not as character array. Correct me if I am wrong.


A string is a sequential collection of Unicode characters that is used to represent text. A String object is a sequential collection of System.Char objects that represent a string. The value of the String object is the content of the sequential collection, and that value is immutable.

A String object is called immutable (read-only) because its value cannot be modified once it has been created. Methods that appear to modify a String object actually return a new String object that contains the modification. If it is necessary to modify the actual contents of a string-like object, use the System.Text.StringBuilder class.
(source: http://msdn.microsoft.com/en-us/library/system.string.aspx[^])

An Array by definition is a sequential collection of the same data type accessed through an indexer (offset). So it seems like it. Also, It appears that (specifically with strings) even if you try to alter the contents, a new string is actually returned.



N a v a n e e t h wrote:
MS just wrapped the array copying logic inside these classes. When additional space required, a new array will be created and existing contents will be copied to there.


I can't find any sources for or against this argument, but from what I know and remember, all these collection objects are based on the original ArrayList which inherits directly from the System.Object, whilst all the other ValueTypes inherit from System.ValueType, so I'd guess they're different. Also, aren't arrays pushed onto the stack whilst the other dynamic datastructures get pushed onto the heap? I'm not too sure, so don't consider my arguments as final. Indeed, this is becoming something I'm interested in finding out.

Don't forget to vote if the response was helpful


Sig history

"dad" Ishmail-Samuel Mustafa

"There's no point questioning the actions of a c0ck-juggling thunderc*nt" From the book of testy commentary by martin_hughes

Unix is a Four Letter Word, and Vi is a Two Letter Abbreviation

GeneralRe: string and array are immutable? [Modified] Pin
N a v a n e e t h25-Aug-08 7:00
N a v a n e e t h25-Aug-08 7:00 
GeneralRe: string and array are immutable? [Modified] Pin
Mustafa Ismail Mustafa25-Aug-08 9:13
Mustafa Ismail Mustafa25-Aug-08 9:13 

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.