Hi I know that c# has using element....but as you know, using disposes object automatically... clearly, I want the equivalence of with......end with in vb6.0?
Merci
Hi I know that c# has using element....but as you know, using disposes object automatically... clearly, I want the equivalence of with......end with in vb6.0?
Merci
C# doesn't have an equivalent language construct for that.
There's no equivalent to With ... End With in c#.
Here's a comparison chart for you that illustrates differences between vb and c#.
There is no equivalent structure in C#. This is a VB6 / VB.Net feature.
I might be wrong but I don't think there is a "with ... end" equivalent in C#
There is no such syntax construct. Similiar (like USING) exist, but there is no VB6- or Delphi-style WITH. This is done on purpouse, since nesting few with clauses makes code hard to understand.
It's not equivalent, but would this syntax work for you?
Animal a = new Animal()
{
SpeciesName = "Lion",
IsHairy = true,
NumberOfLegs = 4
};
I think the equivalent of
With SomeObjectExpression() .SomeProperty = 5 .SomeOtherProperty = "Hello" End With
would be
{ Var q=SomeOtherExpression(); q.SomeProperty = 5; q.SomeOtherProperty = "Hello"; }
The only real difference is that in vb, the identifier doesn't have a name "q", but is simply a default identifier used when a period is encountered without any other identifier before it.