Generic Interface C# with Example



Generic Interface C# with Example

 	using System;

	namespace CSharpGenerics
	{	
		public interface IGeneric
		{
			void Display();
		}

		public class GenericClass : IGeneric
		{
			T genObject;

			public GenericClass(T argObject) 
			{
			genObject = argObject;
			}

			public void Display()
			{
				Console.WriteLine("Value: " + genObject);
			}
		}

		class UsingGenericInterface
		{
			static void Main( )
			{
				GenericClass msg = new GenericClass("Kuldeep Mishra");
				msg.Display();
			}
		}
	}
 

0 Comment's

Comment Form