2018-09-22から1日間の記事一覧

C# 文字列から数値だけを抜き出す

C#

正規表現で数字だけ抜き出す。 using System.Text.RegularExpressions; string str = Regex.Replace (gameObject.name, @"[^0-9]", ""); Debug.Log (str); ネタ元 http://robamemo.hatenablog.com/entry/2018/03/03/194425

C#リストを逆順に処理する

C#

foreach (MyItem item in items.Reverse()) { // itemに対する処理ここで行う } ネタ元 https://blog.yuizi.com/2010/04/c_9105.html

C#のDictionaryをソートする

C#

Dictionaryの代わりにSortedDictionaryを利用すると、自動でキーを元にソートしてくれます。例 // 宣言:SortedDictionaryとしてインスタンスを作成 var itemTable = new SortedDictionary<int, Item>(); ネタ元 https://takachan.hatenablog.com/entry/2018/04/02/2324</int,>…