A java blog with a collection of examples and tutorials on Java and related technologies. (Under maintenance with continuous updates)
Be in touch with java jazzle or k2java.blogspot.com.
Pages
▼
Wednesday, October 13, 2010
Arrays in C#
public static void Main() { int[] arr = {5, 1, 10, 33, 100, 4}; Array.Sort(arr); foreach (int v in arr) Console.WriteLine("Element: {0}", v);
//Making random array DateTime now = DateTime.Now; Random rand = new Random ((int) now.Millisecond);
int [] Arr = new int [12]; for (int x = 0; x < Arr.Length; ++x) { Arr [x] = rand.Next () % 101; }
//jagged array int[][] jagged = new int[3][]; jagged[0] = new int[4]; jagged[1] = new int[3]; jagged[2] = new int[5]; int i; // store values in first array for(i=0; i < 4; i++) jagged[0][i] = i; }
No comments:
Post a Comment