473,785 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"with blocks" in c#

Hi

I'm a VB6 developer attempting to learn C# ....and I've stumbled at the
first hurdle of how to use with blocks.

I'm used to writing:

Dim o as someObject

with o.mainProperty
.subProperty1 = "a"
.subProperty2 = "b"
end with

and I can't even figure that out in c#.

Griff
Feb 9 '06 #1
2 1506
Hi Griff,

Unfortunately there is nothing like that in C#. You'll have to address each
property individually.

someObject o = new someObject();
o.subproperty1 = "a";
o.subproperty2 = "b";

HTH
--
MCSD.NET, MCAD, MCT
"Griff" wrote:
Hi

I'm a VB6 developer attempting to learn C# ....and I've stumbled at the
first hurdle of how to use with blocks.

I'm used to writing:

Dim o as someObject

with o.mainProperty
.subProperty1 = "a"
.subProperty2 = "b"
end with

and I can't even figure that out in c#.

Griff

Feb 9 '06 #2
Hi Griff,
there is no such statement in C#. See the reasons for this:

http://www.gotdotnet.com/team/csharp.../ask.aspx#with

Mark Dawson
http://www.markdawson.org
"Griff" wrote:
Hi

I'm a VB6 developer attempting to learn C# ....and I've stumbled at the
first hurdle of how to use with blocks.

I'm used to writing:

Dim o as someObject

with o.mainProperty
.subProperty1 = "a"
.subProperty2 = "b"
end with

and I can't even figure that out in c#.

Griff

Feb 9 '06 #3

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

Similar topics

68
4376
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I don't like the brackets.
0
1423
by: Bill | last post by:
I have only a cursory knowledge of Microsoft's Application Blocks, which seem like they might be pretty cool. I'm wondering if any of these (such as the Exception Handling Application Block) can be considered related to Aspect Orientated Programming (AOP)?
3
1563
by: Arjen | last post by:
Hello, Are the ASP.NET 2.0 "Building Block's" the same this as the Enterprise Library Application Blocks? Thanks! Arjen
5
1884
by: Alexander Myodov | last post by:
Hello, Having heard that Python 2.5 offers some kind of RIIA concept via PEP343, got it downloaded (Windows version) and tried. But it did not work as expected and as wanted. For the time since I first learned Python, the only reason why I just could not use it was inability to localize the lifetime of some variables inside some syntactical "blocks", especially ones in "for"/"while"/"if" statements, but possibly in any "manually...
19
23215
by: (PeteCresswell) | last post by:
I'm going over an application written by somebody else and have encountered what looks to me like nested "With"s. Is this something new with MS Access 2003 or am I losing it? Seems to me that when I tried nesting "With" clauses in MS Access 2000 it was a no-no. Some sample code - in which it looks like they're creating/populating a ..XLS spreadsheet. "Option Explicit" is not specified in the module......
8
1802
by: Rasmus Kromann-Larsen | last post by:
The With Conundrum I'm currently writing a master thesis on (preparations for) static analysis of JavaScript, and after investigating the with statement, it only even more evident to me that the with statement is indeed bad. My initial thoughts on with were based on: http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/ I built some examples to investigate - and later try to "eliminate"
25
2591
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end with
4
4894
by: smashzone | last post by:
Hi all, Can anyone help me with a script to produce an output file of a "df -m" command with ";" seperators. I assume its very easy but I know nothing about Linux/Unix (I'm a newbie) That is: df -m $ df -m Filesystem 1M-blocks Used Available Use% Mounted on /dev/md0 9845 4881 4464 53% /
24
2077
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 types" are always created on the stack, but then showed the "creation" of one w/ operator new. I guess it makes sense, but is it true that: MyValueType t;
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10091
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.