Dictionary<DateTime, string>
を使用することをおすすめします。あなたの文字列については
List<string> splits = "yourSplitsStringArray".ToList();
//Create your Result Dictionary
Dictionary<DateTime, string> result = new Dictionary<DateTime, string>();
//Process your data:
splits.ForEach(x => result.Add(DateTime.Parse(x.Substring(0, 16)), x.Substring(17, x.Length - 17)));
:
|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|
|1|1|-|0|2|-|1|6| |1| 1| :| 3| 3| A| M| a| b| c| .| x| m| l|
だからあなたのDateTimeを16
=>x.Substring(0, 16)
のトータルな長さで[0]
から始まります。
ファイル名は[17]
で始まり、x.Lenght - 17
文字長です。
emのすべてを再度列挙したくないことは知っていますが、必要なものを達成するための最も簡単で実用的な方法だと思います。
最初の分割操作に私の答えの一部を含めることもできます。
しかし:それは辞書DateTime
は一意である必要がありますですキーなので
。 そのようになるかどうか不明な場合は、代わりにList<Tuple<DateTime, string>>
を使用してください。それは辞書に似ています。
これはあなたのLinq
に変更されます:
//Process your data:
splits.ForEach(x => result.Add(new Tuple<DateTime, string>(DateTime.Parse(x.Substring(0, 16)), x.Substring(17, x.Length - 17))));
必要なすべてのプロパティを持つ新しいクラスを作成し、その配列を格納します。 –
これはあなたがいつも得ようとしている形式です.. 11-02-16 11:35 AM xyz.xml –
NMathur