Sometimes it's easier to just do it yourself; see if you get some ideas from this:
using System;
using System.Collections.Generic;
namespace YourNameSpace
{
public class Student
{
public List<int> Scores;
public Student CloneOf;
public Student(string name, params int[] scores)
{
CloneOf = null;
Name = name;
Scores = new List<int>(scores);
}
public string Name { get; set; }
public bool AddScore(int score)
{
try
{
Scores.Add(score);
}
catch { return false; }
return true;
}
public List<int> GetScores()
{
return Scores;
}
public int GetScoreAt(int index)
{
return (int)Scores[index];
}
public int GetScoreTotal()
{
int sum = 0;
foreach (int score in Scores)
{
sum += score;
}
return sum;
}
public int GetScoreCount()
{
return Scores.Count;
}
public int GetScoreAverage()
{
return GetScoreTotal() / GetScoreCount();
}
public void DestroyScores()
{
Scores = new List<int>();
}
}
public static class StudentExtensions
{
public static Student Clone(this Student stdnt)
{
var clone = new Student
(
stdnt.Name,
stdnt.Scores.ToArray()
)
{
CloneOf = stdnt
};
return clone;
}
public static void SaveEdits(this Student stdnt, Student clone)
{
if (clone == null || clone.CloneOf == null || clone.CloneOf != stdnt)
{
throw new ArgumentException("Invalid clone argument");
}
if (stdnt.Scores != clone.Scores) stdnt.Scores = clone.Scores;
if (stdnt.Name != clone.Name) stdnt.Name = clone.Name;
}
}
}
Usage example:
Student s1 = new Student("S1", 89,92,100,78);
Student s2 = s1.Clone();
s2.Scores[2] = 87;
s1.SaveEdits(s2);