July 11th, 2013, 03:55 PM
Print each object in a list.
I'm working on making an interactive periodic table, so I have an Element class, that gets created for each new Element. The element class has a ToString() method. I want the ability to give a quick print out of the elements in the currently list, so I attempted to do a foreach loop, but the following code is only printing what the object is, not the ToString() method in the Element class.
How can I use the object's ToString() methid, not (I assume) System.Object's?
foreach (object o in elementList)
Note: This is only my 2nd day in C#, so I apologize if this is a simple question. Thanks in advance for any help!
Click Here to Expand Forum to Full Width