"with blocks" in c#

  • Thread starter Thread starter Griff
  • Start date Start date
G

Griff

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
 
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
 
Back
Top