471,348 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

equivalent of with

What is the equivalent in C# for VB
With <object>

.something()

End with
Feb 7 '06 #1
7 1438
There isn't one. That's a VB specific feature.

"Ofer" <Of**@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
What is the equivalent in C# for VB
With <object>

.something()

End with

Feb 7 '06 #2
The simple answer is "Not". And I believe somebody in MS C# group
explained the reason why this is not implemented, you need google that.

Ofer wrote:
What is the equivalent in C# for VB
With <object>

.something()

End with

Feb 7 '06 #3
Did not find the reason but I hope they will add something like that in the
future.

"John Sun" wrote:
The simple answer is "Not". And I believe somebody in MS C# group
explained the reason why this is not implemented, you need google that.

Ofer wrote:
What is the equivalent in C# for VB
With <object>

.something()

End with

Feb 7 '06 #4

"Ofer" <Of**@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
| Did not find the reason but I hope they will add something like that in
the
| future.
|
| "John Sun" wrote:
|
| > The simple answer is "Not". And I believe somebody in MS C# group
| > explained the reason why this is not implemented, you need google that.
| >
| > Ofer wrote:
| > > What is the equivalent in C# for VB
| > > With <object>
| > >
| > > .something()
| > >
| > > End with
| >

The C# team and community at large already rejected this request, and it
looks like C# will not spoil another keyword for this. Of course you can
always try to make them change their minds by posting a suggestion to the
feedback center http://lab.msdn.microsoft.com

Willy.
Feb 7 '06 #5
This gets regular airings...

The main point is: why? it offers no significant benefit: with exactly the
same effort you could just do:

SomeClass instance = <object>; // your term... presumably accessed via a
property or function etc
instance.something();

And if you want to strictly scope the variable:

{
SomeClass instance = <object>; // your term... presumably accessed via a
property or function etc
instance.something();
}

It would honestly add very little...

This is very different to "using", "lock", etc, as these do offer a
significant benefit - both in terms of saved keystrokes and consistent
object access / disposal.

Marc
Feb 7 '06 #6
The beauty of the alternative demonstrated by Marc is that you can use it on
many objects at once, where the VB "With" can only be used on one object at a
time.

Another problem with "With" is that you lose the intellisense within a large
"With" block - you have to scroll to the top to see what you're "With"ing.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"Marc Gravell" wrote:
This gets regular airings...

The main point is: why? it offers no significant benefit: with exactly the
same effort you could just do:

SomeClass instance = <object>; // your term... presumably accessed via a
property or function etc
instance.something();

And if you want to strictly scope the variable:

{
SomeClass instance = <object>; // your term... presumably accessed via a
property or function etc
instance.something();
}

It would honestly add very little...

This is very different to "using", "lock", etc, as these do offer a
significant benefit - both in terms of saved keystrokes and consistent
object access / disposal.

Marc

Feb 7 '06 #7
Hi,

It wont be added in future versions, take a look at
http://www.gotdotnet.com/team/csharp...lumns/ask.aspx for reasons why
is not present.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ofer" <Of**@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
What is the equivalent in C# for VB
With <object>

.something()

End with

Feb 7 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by John | last post: by
2 posts views Thread by Michael Foord | last post: by
6 posts views Thread by Frank Rachel | last post: by
7 posts views Thread by Tim Conner | last post: by
9 posts views Thread by Paul Brownjohn | last post: by
10 posts views Thread by karch | last post: by
9 posts views Thread by Alan Silver | last post: by
48 posts views Thread by Daniel Crespo | last post: by
14 posts views Thread by grid | last post: by
4 posts views Thread by pcnerd | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.