How to access inner list item in c#
  • Hi all i am working on windows phone and now i am facing issue to access inner list item through outer list index in c#
    i have a json class like follow
    public List<List<string>> Professions { get; set; }
  • 2 Comments sorted by
  • Hello
    You can use foreach or for loop to access list items For example

    using System;
    using System.Collections.Generic;

    class Program
    {
    static void Main()
    {
    List<int> list = new List<int>();
    list.Add(2);
    list.Add(3);
    list.Add(7);

    foreach (int prime in list) // Loop through List with foreach.
    {
    Console.WriteLine(prime);
    }

    for (int i = 0; i < list.Count; i++) // Loop with for.
    {
    Console.WriteLine(list[i]);
    }
    }
    }
    You can also Access them like this
      int index = // some index
    // now, ClassName[index] is a Person
    // and we can access its accessible properties Replace ClassName with your class name in below line
    Console.WriteLine(ClassName[index].Professions);

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

Top Posters Weekly

Optimum Creative