Click here to Skip to main content
15,907,001 members
Home / Discussions / C#
   

C#

 
GeneralData Display question. Pin
Michael P Butler21-Apr-04 7:30
Michael P Butler21-Apr-04 7:30 
GeneralRe: Data Display question. Pin
Heath Stewart21-Apr-04 8:37
protectorHeath Stewart21-Apr-04 8:37 
GeneralRe: Data Display question. Pin
Michael P Butler21-Apr-04 9:55
Michael P Butler21-Apr-04 9:55 
GeneralRe: Data Display question. Pin
Heath Stewart21-Apr-04 10:04
protectorHeath Stewart21-Apr-04 10:04 
GeneralRe: Data Display question. Pin
Michael P Butler21-Apr-04 10:21
Michael P Butler21-Apr-04 10:21 
Questionany ideas on this security problem?? Pin
LongRange.Shooter21-Apr-04 7:29
LongRange.Shooter21-Apr-04 7:29 
GeneralSimulation of VB6 Style Default properties Pin
Fakher Halim21-Apr-04 6:25
Fakher Halim21-Apr-04 6:25 
GeneralRe: Simulation of VB6 Style Default properties Pin
Heath Stewart21-Apr-04 6:59
protectorHeath Stewart21-Apr-04 6:59 
GeneralRe: Simulation of VB6 Style Default properties Pin
Fakher Halim21-Apr-04 7:26
Fakher Halim21-Apr-04 7:26 
GeneralRe: Simulation of VB6 Style Default properties Pin
Heath Stewart21-Apr-04 8:29
protectorHeath Stewart21-Apr-04 8:29 
GeneralRe: Simulation of VB6 Style Default properties Pin
scadaguy21-Apr-04 10:16
scadaguy21-Apr-04 10:16 
GeneralRe: Simulation of VB6 Style Default properties Pin
Daniel Turini21-Apr-04 7:32
Daniel Turini21-Apr-04 7:32 
GeneralRe: Simulation of VB6 Style Default properties Pin
Fakher Halim21-Apr-04 8:34
Fakher Halim21-Apr-04 8:34 
GeneralCorrection Pin
Jeff Varszegi21-Apr-04 9:48
professionalJeff Varszegi21-Apr-04 9:48 
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 

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.