Csharp/CSharp Tutorial/struct/struct array
Definite Assignment and Array of struct
using System;
struct Complex
{
public Complex(float real, float imaginary)
{
this.real = real;
this.imaginary = imaginary;
}
public override string ToString()
{
return(String.Format("({0}, {0})", real, imaginary));
}
public float real;
public float imaginary;
}
class MainClass
{
public static void Main()
{
Complex[] arr = new Complex[10];
Console.WriteLine("Element 5: {0}", arr[5]); // legal
}
}
Element 5: (0, 0)