Inside the btnStart_Click you are declaring another copy of the array arrayOrd
.
A copy local to the event handler that is no more accessible at the end of the event and then destroyed
Remove the declaration type char[]
and your code will reference to the global variable
protected void btnStart_Click(object sender, EventArgs e)
{
arrayOrd = txtOrd.Text.ToCharArray();//Putter txtOrd i array
}
However, your code is still weak, if the user press the button btnSjekkOrd
before the start button the arrayOrd is still null and the error will raise again
protected void btnSjekkOrd_Click(object sender, EventArgs e)
{
if(arrayOrd == null) return; // or message to press the start button
for (int i=0; i <= arrayOrd.Length; i++ )
....