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
@Mark Byers answer is good but the variable x will live after properties are set. And you can't use name x again (in same block).
Try this (And object must be reference type in this sample) :
void Main()
{
var myObject1 = new Foo();
var myObject2 = new Hoo();
//elided...
{
var _ = myObject1;
_.MyPropertyA = 2;
_.MyPropertyB = "3";
}
{
var _ = myObject2;
_.MyPropertyX = 5;
_.MyPropertyY = "asd";
}
}