473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1496
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
6
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The...
7
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
9
by: Paul Brownjohn | last post by:
Hello I am new both to this group and to C# programming having spent the last 15 years or so writing C and VB. You will forgive I hope if I am asking the totally obvious but it is a question...
10
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
48
by: Daniel Crespo | last post by:
Hi! I would like to know how can I do the PHP ternary operator/statement (... ? ... : ...) in Python... I want to something like: a = {'Huge': (quantity>90) ? True : False} Any...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
4
by: pcnerd | last post by:
I've been playing with "classic" VB since version 3. I have VB6 Learning Edition. Recently, I wanted to try VB.NET. I got a beginner's book with a CD with the software & installed it. There are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.