{I+=codeWee;}
[C#] interface Sample
interface ISampleInterface
{
	void SampleMethod();
}

class CSampleClass1 : ISampleInterface
{
	void SampleMethod()
	{
		// Method implementation.
	}
}

class CSampleClass2 : ISampleInterface
{
	void SampleMethod()
	{
		// Method implementation.
	}
}

class Program
{
	static void Main()
	{
		ISampleInterface a = CreateInstance(1);
		ISampleInterface b = CreateInstance(2);

		a.SampleMethod();
		b.SampleMethod();
	}

	static public ISampleInterface CreateInstance(int n)
	{
		switch (n)
		{
			case 1:
				return new CSampleClass1();
			case 2:
				return new CSampleClass2();
			default:
				return new CSampleClass1();
		}
	}
}
HTML | PHP | C++ | DirectX11 | Javascript | C# | HTML5 | ASP | SQL | General | CSS | Oculus Rift | Unity3d | Virtools SDK | Tip | NSIS | PowerShell | node.js | Web API | RTSP | All
Copyright© 2016 CodeWee.com All rights reserved.