I would like to add (within a loop) class instances to a list but on each iteration I only want to update one field of the class. Here is my illustation example:
public class info
{
public string aninmalorhuman;
public string type;
}
var temp = new info();
var infolist = new List<info>();
temp.aninmalorhuman = "animal";
temp.type = "dog";
infolist.Add(temp);
temp.type = "cat";
infolist.Add(temp);
If I give infolist to the console it prints "animal cat" & "animal cat". I guess first for my learning why??? and second how do I make it print "animal dog" & "animal cat" please?
UPDATE
I see how this was not the smartest question but I had beginners confusion so I do not really see why this is voted down. Anyways, thank you to those who responded for clearing this up.