I create the Array cardImages in Class KartenClass
public Image[][][] cardImages = new Image[9][][];
I wrote a method called arrbef() to fill it
public void arrbef()
{
this.cardImages[0][0] = new Image[3] { global::WindowsFormsApplication4.Properties.Resources.Card, global::WindowsFormsApplication4.Properties.Resources.CardBack, global::WindowsFormsApplication4.Properties.Resources.CardSet };
this.cardImages[0][1] = new Image[3] { global::WindowsFormsApplication4.Properties.Resources.Card, global::WindowsFormsApplication4.Properties.Resources.CardBack,
etc....
and in my Form i call the method arrbef and try to fill it.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Karten : Form
{
KartenClass karten = new KartenClass();
int standort = 0;
public Karten()
{
InitializeComponent();
KartenClass.karten[0].arrbef();
}
But when i click on the button which links to this form, i get the following Error:
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei WindowsFormsApplication4.KartenClass.arrbef() in c:\Users\david.kresse\Documents\Visual Studio 2012\Projects\WindowsFormsApplication5\KartenClass.cs:Zeile 24.
bei WindowsFormsApplication4.Karten..ctor() in c:\Users\david.kresse\Documents\Visual Studio 2012\Projects\WindowsFormsApplication5\Karten.cs:Zeile 22.
bei WindowsFormsApplication4.Start.btnStartGoToKarten_Click(Object sender, EventArgs e) in c:\Users\david.kresse\Documents\Visual Studio 2012\Projects\WindowsFormsApplication5\Start.cs:Zeile 394.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
What did i do wrong? I did exactly the same with another array (which was one dimensonal).
I hope you can help.