1

I have a List<object>, and its first element is a List<double>, I mean:

//----

List <object> lista = new List<object>();

List <double> listain = new List<double>();

Lista.Add(listain);


//---

Now I want to obtain the data that is in lista[0] (this element is the List<double>), but I don't know how to do it; I've tried with a foreach, but that doesn't work with objects.

Any idea?


How to cut a .txt file in list view

I wondered if there is a way to cut a .txt file in a one word per line view. I tried the following command:

cut -f1 -d' ' test.txt

this works only partially. I also tried 'awk' but had the same issues. To make sure you understand what I mean I give a little example of the text:

Lorem Ipsum is simply dummy text of the printing and typesetting industry. 

This is the output I want:

Lorem
Ipsum
is
simply
dummy
text
of
the
printing
and
typesetting
industry

Is it possible to do this with a simple command or does this take a little shell script?

4

6 に答える 6

2

まず、あなたの質問に答えるために: 最初の要素を正しいクラスにキャストする必要があります

foreach (List<double> doubleList in lista){
    foreach(var number in doubleList){
    // do whatever you want 
    }
}

第二に、すでにテンプレートを使用しているのに、なぜs のList<double>リストに キャストするobjectのでしょうか?

次のようにリストを定義してみてください。

List <object> lista = new List<List<double>>();

プログラミングは変更されませんが、理解しやすくなります。

于 2013-09-29T10:39:30.207 に答える