Obvious NewBee Question
See below. I have a string variable (mystring) that I want to keep information in my partial class. Do I really have to mark it as static to do this?
public partial class NewClass : System.Web.UI.Page
{
static string mystring
protected void ddlFoodChoices_SelectedIndexChanged(object sender, EventArgs e)
{
mystring = "Made it to Food Choices";
}
protected void ddlFoodType_SelectedIndexChanged(object sender, EventArgs e)
{
lblfoodgroups.Text = mystring.ToString();
}
}

AlanRank #669 · 3.6K reputationPosted Jul 24, 2007, 10:17 AM EDT
If you only want to access it from instance methods (as in the code you posted), then you can make it an instance field instead:
protected string mystring;
Bryan Homrighous7 reputationPosted Jul 24, 2007, 12:45 PM EDT
Bryan