开发者

Remove value from array?

How can I take out one line of this array

 开发者_如何学JAVA 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.


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>.


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:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜