[Solved] A List from Property [closed]


Looking at your code the class Result is not a list which I think you are trying to call with List()? not sure..

To create a List<> you can do it multiple ways see below on a few options. Try these in your Main method.

 List<string> stringList = new List<string>();  //creates a List<string> called stringList
        stringList.Add("green");                       //adds the value green to List<string>
        Console.WriteLine("Values in stringList: ");
        stringList.ForEach(Console.WriteLine);         //Outputs values in List<string>
        Console.WriteLine("\n");                       //makes a space between lines in output

        var ergIA = new List<string> {"1", "2", "red", "yellow"}; //creates List<string> called ergIA and assigned four values
        Console.WriteLine("Values in ergIA List: ");
        ergIA.ForEach(Console.WriteLine);                         //Outputs values in List<string>
        Console.WriteLine("\n");                                  //makes a space between lines in output


        Console.WriteLine("Enter value to add to List ergIA: ");
        string userInput = Console.ReadLine();                    //Ask for user input 
        ergIA.Add(userInput);                                     //Adds user input to List<string>   
        Console.WriteLine("\n");
        Console.WriteLine("New List<> values:");
        ergIA.ForEach(Console.WriteLine);
        

solved A List from Property [closed]