tony collier said:
I have
....
enum day {monday, tuesday, wednesday};
myArray[2,2]=5;
i=(int)Enum.Parse(typeof(day), wednesday);
Console.Writeline(i);
Console.Writeline(myArray[2,2]);
outputs:
2
5
as expected. If i try
Console.Writeline(myArray[i,i]);
i get index outside bound of array error. Any ideas anyone?
Could you show a short but complete program which demonstrates the
problem?
asp.net based project>>>
in global.asax :>
......
void Session_Start(Object Sender, EventArgs e)
{
string [,] pricetable=new string [5,12];
Session["pricetable"]=pricetable;
}
............
in page_load
enum bookstores
{
Amazon,
Blackwells,
CoopBookshop,
CountryBookshop,
HistoryBookshopcom,
StudentBookWorldcom,
Swotbooks,
TescoBookStore,
TheBookPlace,
WHSmithOnline,
WHSmithOnlineSD,
ComputerManuals,
ComputerBooks
};
StringBuilder RawHtml=new StringBuilder();
RawHtml.Append( load of screenscraped data );
StringBuilder Bookstore=new StringBuilder();
string [,] pricetable= (string[,])Session["pricetable"];
string price="";
int storeno;
//grab bookstore data between > and < html tags that will correspond
to one of the enum bookstore elements
startindex=RawHtml.ToString().IndexOf(">",startindex)+1;
endindex=RawHtml.ToString).IndexOf"<",startindex);
Bookstore.Append(RawHtml.ToString().Substring(startindex, endindex-
startindex));
// set storeno equal to integer corresponding to bookstore element
storeno=(int)Enum.Parse(typeof(bookstores),Bookstore.ToString());
/* cut out more data from RawHtml and store in pricetable array which is
indexed with a direct correlation between stores and their enumerated
values*/
startindex=RawHtml.ToString().IndexOf("egen>",startindex)+5;
endindex=RawHtml.ToString().IndexOf("<",startindex);
price=RawHtml.ToString().Substring(startindex, endindex-startindex);
pricetable[storeno]=price;
and this is where i get the error. if i do a response.write for storeno
it returns an integer correlating to enum bookstore values and if i do a
response.write for pricetable[0 upto 10 or whatever] this works fine
also.