this http://stackoverflow.com/questions/3975659/calling-the-function-which-is-stored-in-a-string-variable
wrote the following, but there are two errors which i can not solve, do not understand why they are coming
(the error is mentioned with the statement causing it as //error is)
please help
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
//using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string function_name;
function_name = "one";
caller(function_name);
}
static void caller(String function_name)
{
// Get a type from the string
Type type = typeof(_Default);
// Create an instance of that type
Object obj = Activator.CreateInstance(type);
// Retrieve the method you are looking for
MethodInfo methodInfo = type.GetMethod(function_name);
// Invoke the method on the instance we created above
methodInfo.Invoke(obj, null);
}
public void one() //function
{
string a = "\n this is the alphabet a \n";
***//error is***
////Object reference not set to an instance of an object.
////Label1.Text = "one i called";
***//error is***
/////Response is not available in this context.
//// Response.Write(a);
}// function one ends
}