Last active
January 13, 2020 02:02
-
-
Save higaki/3bf9e3b0797f9324b8a64c5f079df959 to your computer and use it in GitHub Desktop.
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
var a = new[]{1, 2, 3, 5}; | |
a.GetType(); // => System.Int32[] | |
a[2]; // => 3 | |
a[4]; // => インデックスが配列の境界外です。 | |
foreach (var i in a) { | |
i.GetType(); // => Int32 | |
Console.WriteLine(i); | |
} | |
var a = new List<int>{1, 2, 3, 5}; | |
a.GetType(); // => System.Collections.Generic.List`1[System.Int32] | |
a[2]; // => 3 | |
a[4]; // => インデックスが範囲を超えています。負でない値で、コレクションのサイズよりも小さくなければなりません。 | |
a.ForEach(i => { | |
i.GetType(); // => Int32 | |
Console.WriteLine(i); | |
}); | |
var h = new Dictionary<string, int>{ | |
{"matz", 54}, | |
{"dhh", 40} | |
}; | |
h.GetType(); // => System.Collections.Generic.Dictionary`2[System.String, System.Int32] | |
h["matz"]; // => 54 | |
h["linda"]; // => 指定されたキーはディレクトリ内に存在しませんでした。 | |
foreach (var kv in h) { | |
kv.GetType(); // => System.Collections.Generic.KeyValuePair`2[System.String, System.Int32] | |
Console.WriteLine($"{kv.Key}: {kv.Value}"); | |
} | |
var gs = new[]{1, 1, 2, 3}.GroupBy(_ => _); | |
gs.GetType(); // => System.Linq.GroupedEnumerable`3[System.Int32, System.Int32, System.Int32] | |
gs.First().GetType(); // => System.Linq.Lookup`2+Grouping[System..Int32, System.Int32] | |
gs.First().Key; // => 1 | |
gs.First().Value; // => 'IGrouping<int, int>' に 'Value' の定義が含まれておらず... | |
var tpl = ("matz", 54); | |
tpl.GetType(); // => System.ValueTuple`2[System.String, System.Int32] | |
tpl.Item1; // => "matz" | |
tpl.Item2; // => 54 | |
tpl.Key // => '(string, int)' に 'Key' の定義が含まれておらず... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment