What BFree said with a slight modification to make it singular, not multiple:
public class ScheduleSelectedItem
{
private string Ad;
public ScheduleSelectedItem(string ad)
{
Ad = ad;
}
public override string ToString()
{
return this.Ad;
}
}
In addition, you need the Add method for your list. Although you are at it, why not just inherit from the list class:
public class ScheduleSelectedItemsList : List<ScheduleSelectedItem>
{
}
Or you can just create an alias like:
using ScheduleSelectedItemsList = List<ScheduleSelectedItem>;
In any case, you can use the new code as follows:
class Program
{
static void Main(string[] args)
{
var slist = new ScheduleSelectedItemsList()
{
new ScheduleSelectedItem("Yusuf")
};
slist.All(item => Console.Write(item.ToString()) );
Console.ReadKey();
}
}
source
share