.net - C# constructor with json style arguments -
i have been watching pluralsight video on generics in c# (so doesnt cover code specifically) , example code has constructor set out in manner i've never seen before:
public circularbuffer() : this(capacity: 10) { } public circularbuffer(int capacity) { // other code here }
the constructor called so
var cb = new circularbuffer(capacity: 3);
what notation , when introduced? there special considerations when using it? there , benefit have on existing solutions?
it named "named arguments" , introduced .net 4.0.
it has been introduced optional arguments , relevant in scenario. named argument syntax, can provide values some of optional arguments without need supply values others.
no special considerations necessary, strictly syntactic sugar used compiler.
Comments
Post a Comment