この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
cli:array [2009/02/01 06:57] 192.168.0.61 |
cli:array [2011/08/23 18:37] admin [array] |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
+ | {{indexmenu_n>13}} | ||
====== array ====== | ====== array ====== | ||
ライン 50: | ライン 51: | ||
array<int,2>^ a2 = gcnew array<int,2>(4,4); | array<int,2>^ a2 = gcnew array<int,2>(4,4); | ||
array<int,2>^ b2 = gcnew array<int,2>{ {1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4} }; | array<int,2>^ b2 = gcnew array<int,2>{ {1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4} }; | ||
+ | </code> | ||
+ | |||
+ | System::Arrayのメソッドでarrayを色々する。 | ||
+ | <code cpp> | ||
+ | #include "stdafx.h" | ||
+ | |||
+ | using namespace System; | ||
+ | |||
+ | void printout(int i) | ||
+ | { | ||
+ | Console::WriteLine(i); | ||
+ | } | ||
+ | int conv(int i) | ||
+ | { | ||
+ | return i*2; | ||
+ | } | ||
+ | |||
+ | bool pred(int i) | ||
+ | { | ||
+ | return i==4; | ||
+ | } | ||
+ | |||
+ | int main(array<System::String ^> ^args) | ||
+ | { | ||
+ | array<int>^ ia = gcnew array<int>{1,2,3,4,5}; | ||
+ | |||
+ | Array::Reverse(ia); | ||
+ | Array::Sort(ia); | ||
+ | |||
+ | Array::ForEach<int>(ia, gcnew Action<int>(printout)); | ||
+ | |||
+ | |||
+ | array<int>^ ia2 = Array::ConvertAll(ia, gcnew Converter<int,int>(conv)); | ||
+ | Array::ForEach<int>(ia2, gcnew Action<int>(printout)); | ||
+ | |||
+ | |||
+ | int i4 = Array::Find(ia2, gcnew Predicate<int>(pred)); | ||
+ | |||
+ | |||
+ | return 0; | ||
+ | } | ||
</code> | </code> |