Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"with" equivalent in C# 1

Status
Not open for further replies.

stillinlife101

Programmer
Feb 15, 2005
29
US
In VB the keyword "With" is used as such:

with TextBox1
.Text = "hi"

or something like that (it's been a while). Is there an equivalent in c#?

Dan
 
Incidentally: this is inside a procedure, so what we have is:

public void DrawGrid(frmMain FormReference)
{
FormReference.ThisFunction(params);
FormReference.ThisFunction(otherparams);
FormReference.OtherFunction(params);
}

What I want to do is

public void DrawGrid(frmMain FormReference)
{
with FormReference
{
ThisFunction(params);
ThisFunction(otherparams);
OtherFunction(params);
}
}

Or something ot that effect.

Dan
 
Will that create another variable or will it just be a reference to the original?

Dan
 
Sure it creates a variable BUT not another instance. You would have to use New to create another instance.

public void DrawGrid(frmMain FormReference)
{
f frmMain = FormReference; // get shorter name
f.ThisFunction(params);
f.ThisFunction(otherparams);
f.OtherFunction(params);
}



Compare Code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top