Using System. Text; namespace GenericExperiment { class Program { static void Main(string args) { XmlContentReaderBase.Deserialize(); Console.ReadKey(); } } class GameObject : ICloneable { object ICloneable.Clone() { Console. WriteLine("I am the base class"); return null; } } class PlatformObject: GameObject, ICloneable { object ICloneable.Clone() { Console.
WriteLine("I am the derived class"); return null; } } class XmlContentReaderBase where T : GameObject, new() { static public object Deserialize() { T obj = new T(); ((ICloneable)obj).Clone(); return obj; } } } Output: I am the derived class.
I wrote an implementation very close to this and see Clone referencing the derived object's Clone method (cheated a bit by creating a new object rather than deserializing one). Post more code? Using System.
Text; namespace GenericExperiment { class Program { static void Main(string args) { XmlContentReaderBase.Deserialize(); Console.ReadKey(); } } class GameObject : ICloneable { object ICloneable.Clone() { Console. WriteLine("I am the base class"); return null; } } class PlatformObject: GameObject, ICloneable { object ICloneable.Clone() { Console. WriteLine("I am the derived class"); return null; } } class XmlContentReaderBase where T : GameObject, new() { static public object Deserialize() { T obj = new T(); ((ICloneable)obj).Clone(); return obj; } } } Output: I am the derived class.
No, I am not using the IClonable interface. Clone is the virtual method of GameObject – can poyrazoÄŸlu Nov 15 at 12:05 ok, while copying the code for posting, I realized that I was using the new keyword instead of override, and returning a PlatformObject instead of GameObject (that's why I was using GameObject). Problem solved now.
– can poyrazoÄŸlu Nov 15 at 12:13 There you go :-) Glad you could resolve it. On a side note, I would not recommend calling something Clone if it doesn't implement the ICloneable contract, as that may cause confusion for yourself or someone else down the road. Maybe call it Copy or similar if you don't want to implement ICloneable.
– Eric J. Nov 15 at 18:35 yeah you are right, it may lead to confusion, i'll probably change it to copy or something :) – can poyrazoÄŸlu Nov 150 at 1:13.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.