473,326 Members | 2,126 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,326 software developers and data experts.

Equivalent of VB's "with"

Is there an equivalent of VB's "with" statement in c# ?
Jul 5 '06 #1
9 1486
cp

Mr Flibble wrote:
Is there an equivalent of VB's "with" statement in c# ?
Nope.

cp

Jul 5 '06 #2
Mr Flibble wrote:
Is there an equivalent of VB's "with" statement in c# ?
No.

See http://www.pobox.com/~skeet/csharp/faq/#vb.with

Jon

Jul 5 '06 #3
"Mr Flibble" <mr********@flibbyly.wobbly.n.etwrote in message
news:e8**********@custnews.inweb.co.uk...
Is there an equivalent of VB's "with" statement in c# ?
This a FAQ, and the usual reply is "No, thank God!"

:-)
Jul 5 '06 #4
Mr Flibble wrote:
Is there an equivalent of VB's "with" statement in c# ?
Absolutely not.

--
Hope this helps,
Tom Spink
Jul 5 '06 #5
Ahh, Negatory. Boris, you got plan?

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Mr Flibble" wrote:
Is there an equivalent of VB's "with" statement in c# ?
Jul 5 '06 #6
Also see:
http://www.tangiblesoftwaresolutions...0VB%20With.htm
(excuse the product plug at the bottom)

Basically, the gist of it is that "With" is no better than an abbreviated
variable named "x" - it's obscure and also implies somehow that the block
centers around the object being With'ed (when it really just centers around
something you didn't want to re-type).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"Mr Flibble" wrote:
Is there an equivalent of VB's "with" statement in c# ?
Jul 6 '06 #7
* David Anton wrote:
Also see:
http://www.tangiblesoftwaresolutions...0VB%20With.htm
(excuse the product plug at the bottom)

Basically, the gist of it is that "With" is no better than an abbreviated
variable named "x" - it's obscure and also implies somehow that the block
centers around the object being With'ed (when it really just centers around
something you didn't want to re-type).
" Another alternative is to refactor so that the With block is a new
method with the object passed in as a parameter. You can use a reduced
parameter name length (without making it obscure)."

How do you reduce the parameter name length? can you give me an example?

Cheers,

Signore Flibble
Jul 6 '06 #8
It's just a possibility that may or may not be appropriate.

For example, instead of:
somehorriblelongnameyoudontwanttoretype.methodone( )
somehorriblelongnameyoudontwanttoretype.methodtwo( )
somehorriblelongnameyoudontwanttoretype.methodthre e()
somehorriblelongnameyoudontwanttoretype.methodfour ()

You *could* just call a new method:
YourMethod(somehorriblelongnameyoudontwanttoretype )

and then the new method defined as:
Public Sub YourMethod(ByVal activeobject As Whatever)
activeobject.methodone()
activeobject.methodtwo()
activeobject.methodthree()
activeobject.methodfour()
End Sub

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"Mr Flibble" wrote:
* David Anton wrote:
Also see:
http://www.tangiblesoftwaresolutions...0VB%20With.htm
(excuse the product plug at the bottom)

Basically, the gist of it is that "With" is no better than an abbreviated
variable named "x" - it's obscure and also implies somehow that the block
centers around the object being With'ed (when it really just centers around
something you didn't want to re-type).

" Another alternative is to refactor so that the With block is a new
method with the object passed in as a parameter. You can use a reduced
parameter name length (without making it obscure)."

How do you reduce the parameter name length? can you give me an example?

Cheers,

Signore Flibble
Jul 6 '06 #9
"David Anton" <Da********@discussions.microsoft.comwrote in message
news:49**********************************@microsof t.com...
It's just a possibility that may or may not be appropriate.

For example, instead of:
somehorriblelongnameyoudontwanttoretype.methodone( )
somehorriblelongnameyoudontwanttoretype.methodtwo( )
somehorriblelongnameyoudontwanttoretype.methodthre e()
somehorriblelongnameyoudontwanttoretype.methodfour ()

You *could* just call a new method:
YourMethod(somehorriblelongnameyoudontwanttoretype )

and then the new method defined as:
Public Sub YourMethod(ByVal activeobject As Whatever)
activeobject.methodone()
activeobject.methodtwo()
activeobject.methodthree()
activeobject.methodfour()
End Sub
Even better would be to make YourMethod a method of the Whatever class.
Making too many calls into another object is known as "feature envy," and it
often (though not always) indicates that there's a new method waiting to be
extracted.

///ark
Jul 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
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...
4
by: John S | last post by:
In VB, you could start manipulating a controls properites and methods just by using the statement With <control name> ..Text=gnkn end with Does anyone know if there is anything similar in C#
5
by: DrOrbit | last post by:
In Pascal/Delphi you can say With MyStructure do begin Field1 := something; Field2 := somethingElse; : // and so on... end; "With MyStructure" avoids having to prepend "MyStructure" to...
16
by: abc my vclass | last post by:
C# has VB's "with" command? I like VB's with command, why don't know C# has it or not?
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
6
by: sck10 | last post by:
Hello, Is there the equivalent of the "with" command in c#? protected void SetFocusControl(Control FocusControl) { System.Text.StringBuilder script = New System.Text.StringBuilder();...
24
by: carnold | last post by:
Hello, I'm a developer coming from C++ and Java ... I've going thru "Effective C#" (which highly recommend for people coming from other languages wanting to learn C#), and it states that "value...
13
by: Steve | last post by:
On page 392 of "Javascript the definitive guide" a function is called like this:- <form action="processform.cgi" onsubmit="return validateForm();"> Why, in this instance, is the return...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.