c# - Unable to get result using object -
public object my() { list<string> mystring = new list<string>(); mystring.add("aaaa"); mystring.add("bbb"); return mystring; }
in main
program p1 = new program(); object test = p1.my(); console.writeline(test);
even if converted tolist()
i'm getting system.collection.generic.list
how convert result list , display elements?
you need cast object (test) list<string>
, iterate on elements in list<string>
print them.
try this:
program p1 = new program(); object test= p1.my(); list<string> lst = (list<string>) test; foreach(string item in lst) console.writeline(item);
Comments
Post a Comment