The Array class is the implicit base class for all single and multidimensional arrays.
The static GetValue and SetValue methods access elements in a dynamically created array.
using System;
using System.Collections;
class Sample
{
public static void Main()
{
// Create a string array 2 elements in length:
Array a = Array.CreateInstance(typeof(string), 2);
a.SetValue("hi", 0);
a.SetValue("there", 1);
string s = (string)a.GetValue(0);
// We can cast to a C# array as follows:
string[] cSharpArray = (string[])a;
string s2 = cSharpArray[0];
}
}
| w_w__w_._j__a___v___a__2___s___.___c_o_m__ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |