A
Allan Lembo
Hi Folks
If I create a new instance of an object within a method how can I pass
it back by reference?
For example, the following code, in the context of an ASP.NET page,
returns "Original Label". Why not "New Label"? I realise I could give
CreateSomething a return type of Label and return it that way but in
my case I have more than one parameter that could need reinstancing.
Thanks, Al.
private void Page_Load(object sender, System.EventArgs e)
{
Label l;
l = new Label();
l.Text="Original label";
CreateSomething(l);
Response.Write(l.Text);
}
private void CreateSomething(Label l)
{
l = new Label();
l.Text="New Label";
}
If I create a new instance of an object within a method how can I pass
it back by reference?
For example, the following code, in the context of an ASP.NET page,
returns "Original Label". Why not "New Label"? I realise I could give
CreateSomething a return type of Label and return it that way but in
my case I have more than one parameter that could need reinstancing.
Thanks, Al.
private void Page_Load(object sender, System.EventArgs e)
{
Label l;
l = new Label();
l.Text="Original label";
CreateSomething(l);
Response.Write(l.Text);
}
private void CreateSomething(Label l)
{
l = new Label();
l.Text="New Label";
}