The error i'm getting is in the title. It has something to do with the array and the for-loop i'm having. I'm trying to store letters from a textbox in a array and then in a session and then search trough those letters in a for-loop and check if the letters in the array is equal to another letter from a txtbox. well....hope some of you know what's wrong. (There is some norwegian letters in there, but don't worry about them) Here is the code from the error:
Linje 30: protected void btnSjekkOrd_Click(object sender, EventArgs e)
Linje 31: {
Linje 32: for (int i=0; i < arrayOrd.Length; i++ )
Linje 33: {
Linje 34: if (txtBokstavSjekk.Text.Length == arrayOrd[i])
Here's all the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
//Session
char [] arrayOrd;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["arrayOrd"] != null)
{
arrayOrd = (char[])Session["arrayOrd"];
}
}
protected void Page_Unload(object sender, EventArgs e)
{
Session["arrayOrd"] = arrayOrd;
}
protected void btnStart_Click(object sender, EventArgs e)
{
char[] arrayOrd = txtOrd.Text.ToCharArray();//Putter txtOrd i array
}
protected void btnSjekkOrd_Click(object sender, EventArgs e)
{
for (int i=0; i <= arrayOrd.Length; i++ )
{
if (txtBokstavSjekk.Text.Length == arrayOrd[i])
{
labRiktigBokstav.Text += arrayOrd[i];
}
else {
labFeilBokstaver.Text += "<b>" + arrayOrd[i] + "<b/>";
}
}
}
}