Given object initializers:
Foo foo = new Foo{ Name = "Jhon", Value = 2, IsMale = true };
Can they be somehow used elsewhere?(outside object construction) So that insted of using:
foo.Name = "Name";
foo.Value = 5;
...
foo.DoSth();
To just use something like:
Name = "Name";
Value = 5;
...
DoSth();
Given that this is outside the class hierarchy of foo. That is to avoid places where you use one object's members many many times.
For example in VB/GML(GameMaker's scripting language) one can use:
with(foo)
{
Name = "Name";
Value = 5;
...
DoSth();
}
Instead of foo.something
So is there something like this in C#?