T
T
TheTalion2016-11-04 09:14:20
C++ / C#
TheTalion, 2016-11-04 09:14:20

Typed sheet, search objects from first to last?

I don’t understand how to make it possible to get all objects in a row from a sheet of indefinite size and, in turn, display some values ​​​​from each object to the console.
I thought it was worth creating a for loop, checking the size of the sheet and then getting objects by index, but FindIndex returns an int, and I need a reference to object to be returned so that I can get some values ​​​​from this object later.

var _List = List<Class>();
for (int i = 0; i < _List.Count; i++)
        {
          var _firstList = _List.//какая-то функция//(i//номер записи//);
          Console.WriteLine("" +_List.perem);
        }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
TheTalion, 2016-11-04
@TheTalion

In short, I found the answer. This method simply eluded me, although I had re-read all the methods of the sheet 3 times before.
Who cares:

var _List = List<Class>();
_List.Sort();
var _checkObj =  _List.ElementAt(_List.FindIndex(i));
Console.WriteLine("" +_checkObj.perem);

S
Stanislav Silin, 2016-11-04
@byme

Read a little literature, this is not a question at all ...

V
VoidVolker, 2016-11-04
@VoidVolker

var myList = new List<string>(){ "item 1", "item 2", "item 3" };
// Обычный цикл по списку:
foreach (string str in myList)
{
    Console.WriteLine("Item is: {0}", str);
}
// Лямбда:
myList.ForEach( (str) =>
{
    Console.WriteLine("Item is: {0}", str);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question