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

Home Posts Topics Members FAQ

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

"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 1387
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

68 posts views Thread by Marco Bubke | last post: by
3 posts views Thread by Arjen | last post: by
5 posts views Thread by Alexander Myodov | last post: by
19 posts views Thread by (PeteCresswell) | last post: by
8 posts views Thread by Rasmus Kromann-Larsen | last post: by
24 posts views Thread by carnold | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | 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.