Click here to Skip to main content
15,897,137 members
Home / Discussions / C#
   

C#

 
GeneralRe: Correction Pin
Fakher Halim21-Apr-04 9:56
Fakher Halim21-Apr-04 9:56 
GeneralRe: Correction Pin
Jeff Varszegi21-Apr-04 11:00
professionalJeff Varszegi21-Apr-04 11:00 
GeneralDataGrid Icon column - paint performance issue Pin
Chris#21-Apr-04 5:38
Chris#21-Apr-04 5:38 
GeneralRe: DataGrid Icon column - paint performance issue Pin
Heath Stewart21-Apr-04 7:06
protectorHeath Stewart21-Apr-04 7:06 
GeneralRedim in c# Pin
amatyasik21-Apr-04 5:19
amatyasik21-Apr-04 5:19 
GeneralRe: Redim in c# Pin
Andrew McCarter21-Apr-04 5:27
Andrew McCarter21-Apr-04 5:27 
GeneralRe: Redim in c# Pin
amatyasik21-Apr-04 5:30
amatyasik21-Apr-04 5:30 
GeneralRe: Redim in c# Pin
Jeff Varszegi21-Apr-04 5:54
professionalJeff Varszegi21-Apr-04 5:54 
Andrew's message is entirely correct: there is no Redim, and the ArrayList class addresses the problem by rendering things like Redim unnecessary. Here's how you can "redim preserve" an array in C#, if you choose not to use ArrayList or something like it:

<br />
string[] toto = new string[3];<br />
// ...<br />
// ... Muck with the array's values<br />
// ...<br />
<br />
string[] newToto = new string[4];<br />
Array.Copy(toto, 0, newToto, 0, toto.Length); // Here's the "preserve" part<br />
toto = newToto;<br />
newToto = null// Not always necessary<br />


ArrayList is nothing magic, just a wrapper around an array. The major differences between the above code snippet and the use of ArrayList is that ArrayList takes care of the array copying seamlessly for you, that ArrayList keeps track of how many items have been added to it (you have to keep this in an extra variable otherwise), and that every index access incurs the overhead of a method call. This method call overhead can significantly slow down code that heavily uses an ArrayList, which is why when I'm writing code for speed (which I do much, but not all, of the time) I prefer to just manage my own arrays.

A tip: if you know in advance roughly the number of items you might see, you can save yourself some ArrayList-internal array copying by setting the initial capacity in the constructor.


Regards,

Jeff Varszegi
GeneralEnable/Disable the keyboard and mouse Pin
lajiyo21-Apr-04 5:19
lajiyo21-Apr-04 5:19 
GeneralRe: Enable/Disable the keyboard and mouse Pin
Dave Kreskowiak21-Apr-04 8:07
mveDave Kreskowiak21-Apr-04 8:07 
GeneralRe: Enable/Disable the keyboard and mouse Pin
Heath Stewart21-Apr-04 9:47
protectorHeath Stewart21-Apr-04 9:47 
GeneralRe: Listview Problem Pin
Nick Parker21-Apr-04 4:57
protectorNick Parker21-Apr-04 4:57 
GeneralRe: Listview Problem Pin
Heath Stewart21-Apr-04 6:42
protectorHeath Stewart21-Apr-04 6:42 
GeneralRe: Listview Problem Pin
Nick Parker21-Apr-04 17:15
protectorNick Parker21-Apr-04 17:15 
GeneralRe: Listview Problem Pin
Heath Stewart22-Apr-04 2:22
protectorHeath Stewart22-Apr-04 2:22 
GeneralRe: Listview Problem Pin
Nick Parker22-Apr-04 4:00
protectorNick Parker22-Apr-04 4:00 
GeneralRe: Listview Problem Pin
Reinier van de Wetering21-Apr-04 22:24
Reinier van de Wetering21-Apr-04 22:24 
GeneralRe: Listview Problem Pin
Heath Stewart22-Apr-04 2:35
protectorHeath Stewart22-Apr-04 2:35 
GeneralAdd Permission to a Registrykey with C# Pin
Sebastian Wittig21-Apr-04 4:21
Sebastian Wittig21-Apr-04 4:21 
GeneralRe: Add Permission to a Registrykey with C# Pin
Heath Stewart21-Apr-04 7:14
protectorHeath Stewart21-Apr-04 7:14 
GeneralRe: Add Permission to a Registrykey with C# Pin
Sebastian Wittig21-Apr-04 21:08
Sebastian Wittig21-Apr-04 21:08 
GeneralDataGridBoolColumn Pin
bertcox21-Apr-04 4:20
bertcox21-Apr-04 4:20 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart21-Apr-04 7:16
protectorHeath Stewart21-Apr-04 7:16 
GeneralRe: DataGridBoolColumn Pin
bertcox21-Apr-04 21:53
bertcox21-Apr-04 21:53 
GeneralRe: DataGridBoolColumn Pin
Heath Stewart22-Apr-04 2:29
protectorHeath Stewart22-Apr-04 2:29 

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.