How to write similar code D?
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Feb 9 16:02:31 PST 2015
Tell me, please, how to write similar ะก# code D:
using System;
using System.Linq;
public class Test
{
public static void Main()
{
var query = Enumerable.Range(2, 10)
.Select(c => new { Length = 2 * c, Height = c * c - 1,
Hypotenuse = c * c + 1 })
.Select(x => string.Format("{0,4}{1,4}{2,4}", x.Height,
x.Hypotenuse, x.Length));
foreach (var x in query)
Console.WriteLine(x);
}
}
Output:
3 5 4
8 10 6
15 17 8
24 26 10
35 37 12
48 50 14
63 65 16
80 82 18
99 101 20
120 122 22
More information about the Digitalmars-d-learn
mailing list