Quote:
Originally Posted by dampyr
This code:
Code:
namespace ClassLibrary1
{
public class content:ICloneable
{
public int val;
}
public class cloner:ICloneable
{
public content mycontent = new content();
public cloner(int newval)
{
mycontent.val = newval;
}
public object clone()
{
cloner clonedcloner=new cloner();
return clonedcloner.mycontent.Clone();
return clonedcloner;
}
Throw next errors:
-ClassLibrary1.cloner does not contain a constructor that takes 0 arguments
-ClassLibrary1.content' does not contain a definition for 'Clone' and no extension method 'Clone' accepting a first argument of type 'ClassLibrary1.content' could be found (are you missing a using directive or an assembly reference?)
What i am doing wrong?
|
Within the clone method you cread a cloner with new cloner() - using a constructor with 0 arguments. The cloner class, however, defines a constructor that requires 1 argument of type int.