Initializing Anonymous Type Arrays : Array « Data Structure « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
  static void Main()
  {
          var worldCup2006Finalists = new[]{new
          {
              TeamName = "France",
              Players = new string[]
              {
                  "A", "B","C", "D",
              }
          },
          new
          {
              TeamName = "Italy",
              Players = new string[]
              {
                  "Q", "W","E", "R",
              }
          }
      };
      Print(worldCup2006Finalists);
  }

  private static void Print<T>(IEnumerable<T> items)
  {
      foreach (T item in items)
      {
          Console.WriteLine(item);
      }
  }
}








11.1.Array
11.1.1.A one-dimensional array.
11.1.2.Declaring and Accessing an Array
11.1.3.Initializing Anonymous Type Arrays
11.1.4.System.Array is a base class for all arrays in C#
11.1.5.Methods Defined by Array
11.1.6.Declare the array and instantiate the array
11.1.7.Set array element value by index(subscript)
11.1.8.Array Declaration with initialization
11.1.9.Use for each loop to output elements in an array
11.1.10.Array Inherited Members: get array type
11.1.11.Array Inherited Members: Rank and Length
11.1.12.Array Inherited Members: GetLength(0)
11.1.13.Use ArraySegment to store string array
11.1.14.Array.SequenceEqual