FW: [Mono-list] Derived classes returning an object that is derived

Daniel Morgan danmorg@sc.rr.com
Sun, 14 Apr 2002 13:56:59 -0400


Ok.  Here is my updated one.  This work though.  I just hope it is
correct.  Thanks for the help in #mono to duncan and rxdan.

using System;

namespace MyStuff
{
	public interface IParameter
	{
		string ParameterName{get;set;}
	}

	public class Parameter : IParameter 
	{
		private string parmName = null;

		public string ParameterName 
		{
			get 
			{
				return parmName;
			}

			set 
			{
				parmName = value;
			}
		}
	}

	public interface ICommand
	{
		IParameter CreateParameter();
	}

	public class Command : ICommand
	{
		IParameter ICommand.CreateParameter()
		{
			return CreateParameter();
		}

		public Parameter CreateParameter()
		{
			return new Parameter();
		}
	}

	class MainDriver
	{
		[STAThread]
		static void Main(string[] args)
		{
			Command cmd = new Command();		
		}
	}
}

-----Original Message-----
From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com] On
Behalf Of Daniel Morgan
Sent: Sunday, April 14, 2002 12:53 PM
To: mono-list@ximian.com
Subject: [Mono-list] Derived classes returning an object that is derived

Hello,

I have a general C# question about interfaces and their derived classes.
I've been pulling my hair out on this.  How is the function
CreateParameter in Command supposed to be defined?

[...]