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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C#'s equivalent to Delphi's "WITH"-statement.

Status
Not open for further replies.

VuurSnikkel

Programmer
Sep 8, 2003
16
NL
Hi there...


I've been programming in Delphi for many years now and although I really like its development environment and underlying Object Pascal language, I think it's about time to migrate to .Net (C# mainly), since the next version of Delphi (8.0) will quite probably be the last. Besides, Delphi 8.0 will also feature .Net-compatibility, so I might as well completely switch to .Net.

I was just wondering if there is an equivalent to Delphi's handy (some people will probably disagree) "WITH"-statement.

Instead of writing something like this:

SomeForm.SomeElement.Caption:=SomeForm.SomeElement.Caption + 'Blablabla.'

Delphi can use a shorthand version:

With SomeForm.SomeElement Do
Caption:=Caption + 'Blablabla.'

Does C# have an equivalent statement to work with structs and/or classes?


GRTZ,

(Sn)Ik.
 
Yes there is a similar WITH statement in .NET and it would be like


Not using WITH statement
SomeForm.SomeElement.Caption +=SomeForm.SomeElement.Caption + 'Blablabla.'

Using WITH statement
With SomeForm.SomeElement

.Caption += 'Blablabla.'
End With


-Kris
 
C# does not contain a With statement although Visual Basic .Net does. Since you're interested in C#, I thought might want to know!

Jose
 
Too bad... Ah well, I will have to learn to do without. Thanks for the reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top