tags:

views:

60

answers:

2

Hello friend,

How can I take out one line of this array

  array< array< int^ >^ >^ sample = gcnew array< array< int^ >^ >{
        gcnew array<int>{0, 0, 0, 0, 0},
        gcnew array<int>{1, 1, 1, 1, 1},
        gcnew array<int>{2, 2, 2, 2, 2},
    };

So it would be :-

  array< array< int^ >^ >^ sample = gcnew array< array< int^ >^ >{
        gcnew array<int>{0, 0, 0, 0, 0},
        gcnew array<int>{2, 2, 2, 2, 2},
    };

Rajesh.

A: 

for ( i = 0; i < n; i++ ) { if ( a[i] == target ) break; }

while ( ++i < n ) a[i - 1] = a[i]; --n;

The actual process doesn't include a delete step, it's just the shift step:

bachchan
A: 

While you can use Array::Resize to resize your array and use the shift method bachchan mentions, you generally don't add or remove items from a C++/CLI array.

If you need add or remove items dynamically from a collection, look into using the System::Collections::Generic::List<T> type (see MSDN).

Depending on what you're doing with the collection, you can use even more sophisticated structures, e.g. HashSet<T> or Dictionary<K, V>.

Chris Schmich