Как преобразовать список объектов в список строк.
I write a code for Classes i saved the data in the list of user defined type in which i want to delete the data from the user defined type list so if the list contains the data then it will remove it from the list so i use the function of list that is Contain but in contain function it only accept the string data Plz tell me how should i convert the user defined list to the string list. Then i can check the following data is avaible or not then it will delete it from th
Что я уже пробовал:
public void remove_item(List<Male_zone>mens, Male_zone m) { List<string> asobj = new List<string>(); asobj = mens.Cast<string>().ToList(); if (asobj.Contains(m.m_item)) { asobj.Remove(m.m_item); Console.WriteLine("Successfully delete"); } else { Console.WriteLine("Not Found"); } }
Main Function
Male_zone mens121 = new Male_zone(); Console.WriteLine("Please Enter the name of the item"); mens121.m_item = Console.ReadLine(); mens121.remove_item(male_outlet, mens121);