This can make constructors easier, especially for immutable types (which are important for streaming) - see here for a full discussion . Not as good as it should be, but better than having a lot of overload. You obviously cannot use object initializers with immutable objects, so the usual one:
new Foo {Id = 25, Name = "Fred"}
not available; I will agree:
new Foo (Id: 25, Name: "Fred")
, , . , IMO, () .
COM , COM- - .
; , ? - / ( ); :
[XmlElement("foo", Namespace = "bar")]
( ctor, "foo" ) . , :
SomeMethod("foo", SecondArg = "bar");
( , )
... , , SecondArg? SecondArg SomeMethod "bar" SecondArg "bar" .
, # 3.0:
static void SomeMethod(string x, string y) { }
static void Main()
{
string SecondArg;
SomeMethod("foo", SecondArg = "bar");
}
, SecondArg , , varialble ..
.
</" > - 280Z28: , , . , . , , , {} . .
[AttributeUsage(AttributeTargets.Class)]
public sealed class SomeAttribute : Attribute
{
public SomeAttribute() { }
public SomeAttribute(int SomeVariable)
{
this.SomeVariable = SomeVariable;
}
public int SomeVariable
{
get;
set;
}
}
[Some(SomeVariable: 3)]
[Some(SomeVariable = 3)]
public class SomeClass
{
}