I have a code looks like the following.
I get message from query string. After that I’m going to get it that to message array(msg_arr).But all of these things in inside the Page_load.
But why does this error show?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string messageIn = Request.QueryString["msg"];
// some code here
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
string[] msg_arr = messageIn.Split(' '); // error shown here
int size = msg_arr.Length;
if(!CheckUserExistAndReporter("messageIn"))
{
// Response.Redirect("~/test.aspx");
}
else
{
You are declaring the
messageInvariable inside thetry{}block and hence its scope is only within thetry{}block.You should do something like this