In Visual Basic, if you are going to change multiple properties of a single object, there's a With/End With
statement:
Dim myObject as Object
// ' Rather than writing:
myObject.property1 = something
myObject.property2 = something2
// ' You can write:
with myObject
.property1 = something
.property2 = something2
...
End With
I know C# can do it when creating a new object:
Object myObject = new Object { property1 = something, property2 = something2, ...};
But how do I do that if myOject
is already created (like what Visual Basic is doing)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…