Note that the alternative suggested by Stefan has the additional benefit of
allowing you do use more than one shortcut at the same time. The 'With'
block (in VB or Delphi) allows only one shortcut at a time via 'With'. In
addition, one of the major drawbacks of 'With' is that intellisense does not
help you identify the object within the block - you have to examine the
header (ok if you have a short block, but otherwise not so good).
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter
"Stefan Simek" wrote:
The C# way is to use the following:
ThisPropertyType temp = mainObj.ThisControl.ThisProperty;
temp.x = whatever;
temp.y = something;
..
..
..
The with statement has been discussed many times before and has always
been declared as evil, because it can lead to hard to debug problems
with overlapping names
HTH,
Stefan
Visual Systems AB (Martin Arvidsson) wrote: Hi!
I often come across situations where i have a major code string for
accessing objects, variables and so on
In delphi, you could enter:
With mainObj.ThisControl.ThisProperty do
begin
x := dsdsa;
end;
instead of mainObj.ThisControl.ThisProperty.x := dsdsa;
It it possbile to do this in c#?
Regards
Martin Arvidsson