Arbeiten mit .NET: C-Sharp/ Grundlagen/ Datentypen/ Strukturen

Aus Wikibooks

Strukturen (struct)[Bearbeiten]

Strukturen sind in C# Wertetypen (s. auch Referenztypen). Alle Datentypen sind in C# über Strukturen gelöst.

  public struct Koordinate
  {
    public double x;
    public double y;
    public double z;	
    public Koordinate(double x, double y, double z)
    {
      this.x = x;
      this.y = y;
      this.z = z;
    }
    public override string ToString()
    {
      return(string.Format("x: {0}, y: {1}, z: {2}", x, y, z));
    }
  }