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

Any Equivalent to VB.NET's With...End With Statement ...

Hi,

I'm new to C#. In VB.NET we have With...End With Statement. Often, I need to
perform several different actions on the same object. For example, I may
need to set several properties or execute several methods for the same
object.

Private Sub UpdateForm()

Button1.Text = "OK"
Button1.Visible = True
Button1.Top = 24
Button1.Left = 100
Button1.Enabled = True
Button1.Refresh()

End Sub

You can write the same in short form like this.

Private Sub UpdateForm2()

With Button1

.Text = "OK"
.Visible = True
.Top = 24
.Left = 100
.Enabled = True
.Refresh()

End With

End Sub

Is there any such facility available in C# too?

Regards,

G.Ashok
-----------------------------------------
Do as you will, try to do it well. That's what I do.

Nov 21 '06 #1
3 2702
I'm new to C#. In VB.NET we have With...End With Statement. Often, I need to
Is there any such facility available in C# too?
No.
"They" say it hurts code clarity...

--
Pozdrav,
Josip Medved
http://www.jmedved.com

Nov 21 '06 #2
"They" say it hurts code clarity...

Much worse than that, it makes it very easy to introduce bugs in order parts
of your code by adding new properties/methods to classes.
Nov 21 '06 #3
Hi Peter,

could you explain how? just curious.

"Peter Morris [Droopy eyes software]" <pe**@droopyeyes.no.com.spamschrieb
im Newsbeitrag news:e0**************@TK2MSFTNGP03.phx.gbl...
>"They" say it hurts code clarity...

Much worse than that, it makes it very easy to introduce bugs in order
parts of your code by adding new properties/methods to classes.

Nov 21 '06 #4

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

Similar topics

4
by: Gregory W. Ernest | last post by:
I am new to Java programming and I was wondering if anyone can tell me the java equivalent to a cin>>...; that is normally used in c++. I want to get user input and automatically assign it to a...
0
by: Eric Wichterich | last post by:
Hello Pythonistas, does anyone know an equivalent python statement for perl's "next"-statement? (Perl's "next" skips a loop cycle and continues with the next loop cycle - it does not abort the...
2
by: JJ Feminella | last post by:
This statement is legal C#: public const string day = "Sunday"; but this statement is not: public const string days = new string { "Sun", "Mon", "Tue" }; The C# Programmer's Reference...
4
by: DKode | last post by:
Hello, I have been using VB.NET for about 5 months and now I decided it's time to start using C#.NET because I like the syntax setup alot more, because it more closely resembles php/perl which...
7
by: TJS | last post by:
is there a server side equivalent to this ?? Inherits System.Windows.Forms.Button
4
by: Scott Johnson | last post by:
Hi I am converting some code from C# to VB.NET and I have come across a command that I can't find the VB equivalent. The C# command is 'lock' and I think it is used to lock a data type from...
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...
14
by: ThunderMusic | last post by:
Hi, The subject says it all. Is there an equivalent, in VB.NET, for the C# statement Lock(Object){} Thanks ThunderMusic
6
by: Jon Paal | last post by:
what is vb equiv. of ++ shown in C# ?
18
by: planetzoom | last post by:
Given the following code: #include <stdio.h> int main(void) { char array = "What is your favorite car?"; void *vp = &array; printf("%s\n", vp);
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.