Created
November 29, 2018 05:02
Constructor with collection Initializer
This file contains 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
string[] ab = new string[] { "a", "b" }; | |
List<string> abcd = new List<string>(ab) { "c", "d" }; | |
// abcd has four elements: "a" "b" "c" and "d" | |
// Resulting list is { 1, 2, 3, 4, 5 } | |
var list2 = new List<int>(list) { 4, 5 }; | |
// Resulting list is { 4, 2, 3 } | |
var list3 = new List<int>(list) { [0] = 4 }; | |
string[] ab = new string[] { "a", "b" }; | |
List<string> abcd = new List<string>(ab) { "c", "d" }; | |
// abcd has four elements: "a" "b" "c" and "d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment