Named parameters: Difference between revisions
Content added Content deleted
(Added PicoLisp) |
(Added C# (4.0)) |
||
Line 94: | Line 94: | ||
<lang c++>foo(foo_params(42).x(7).z(23.54));</lang> |
<lang c++>foo(foo_params(42).x(7).z(23.54));</lang> |
||
=={{header|C sharp|C#}}== |
|||
{{works with|C sharp|C#|4.0}} |
|||
Named parameters were added in C# 4.0. |
|||
<lang csharp>using System; |
|||
namespace NamedParams |
|||
{ |
|||
class Program |
|||
{ |
|||
static void AddWidget(string parent, float x = 0, float y = 0, string text = "Default") |
|||
{ |
|||
Console.WriteLine("parent = {0}, x = {1}, y = {2}, text = {3}", parent, x, y, text); |
|||
} |
|||
static void Main(string[] args) |
|||
{ |
|||
AddWidget("root", 320, 240, "First"); |
|||
AddWidget("root", text: "Origin"); |
|||
AddWidget("root", x: 500); |
|||
AddWidget("root", y: 500, text: "Footer"); |
|||
} |
|||
} |
|||
}</lang> |
|||
Output: |
|||
<pre>parent = root, x = 320, y = 240, text = First |
|||
parent = root, x = 0, y = 0, text = Origin |
|||
parent = root, x = 500, y = 0, text = Default |
|||
parent = root, x = 0, y = 500, text = Footer</pre> |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |