Click here to Skip to main content
16,004,653 members

Comments by Member 14351839 (Top 19 by date)

Member 14351839 3-May-19 17:53pm View    
Did this succesfully clones name and list?

public class Student : ICloneable
{
public List<int> Scores = new List<int>();

public string Name
{ get; set; }

public object Clone()
{
Student obj2 = new Student();
obj2.Scores = this.Scores;
obj2.Name = this.Name;
return obj2;
}
Member 14351839 3-May-19 17:51pm View    
Is this more in the right direction?

public class Student : ICloneable
{
public List<int> Scores = new List<int>();

public string Name
{ get; set; }

public object Clone()
{
Student obj2 = new Student();
obj2.Scores = this.Scores;
obj2.Name = this.Name;
return obj2;
}
Member 14351839 3-May-19 17:35pm View    
Yeah, quite lost. So, I should create an entire new Student object and clone it? How do I implement it to where the form only updates on the ok button event? I don't understand how the clone causes that.
Member 14351839 2-May-19 18:08pm View    
But Clone() is a string method used to clone the string object? So your saying in my case since my classes contain instances I need to build new instances? Guess I'm confused on why I can clone instances.
Member 14351839 1-May-19 19:24pm View    
Yeah, I figured it automatically stored the index based on my selection. I still need to add lots of error checking, but I'm glad we got this working. I've been stuck for days! lol thanks again