Is it possible to clone an object, when it's known to be a boxed ValueType, without writing type specific clone code?
Some code for reference
List<ValueType> values = new List<ValueType> {3, DateTime.Now, 23.4M};
DuplicateLastItem(values);
The partical issue I have is with a value stack based virtual instruction machine. (And Im too lazy to write typeof(int) typeof(DateTime)....)
update I think I confused myself (and a few other people). The working solution I have is;
List<ValueType> values = new List<ValueType> { 3, DateTime.Now, 23.4M };
// Clone
values.Add(values[values.Count() - 1]);
// Overwrite original
values[2] = 'p';
foreach (ValueType val in values)
Console.WriteLine(val.ToString());