Created
October 21, 2018 12:49
-
-
Save mariusGundersen/d8400ad900e4fa3ac57d707e1df1207e to your computer and use it in GitHub Desktop.
Duct-typed extension methods Example 9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example 9: multi or single dimensional arrays? | |
// We define this extension method | |
public static void Add<T>(this List<T> list, params T[] items) | |
=> list.AddRange(items); | |
// And then we can make a flattened matrix | |
var matrix = new List<double> | |
{ | |
{ 1, 0, 0 }, | |
{ 0, 1, 0 }, | |
{ 0, 0, 1 } | |
}; | |
Console.WriteLine(matrix.Count); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment