Click here to Skip to main content
15,885,032 members
Articles / Programming Languages / C#

The Interface Construct in C#

Rate me:
Please Sign up or sign in to vote.
4.77/5 (86 votes)
31 Oct 20078 min read 302.5K   4.8K   171  
Using interfaces as a means to decouple classes, making your application more flexible.
using System;

namespace InterfaceDemo
{
	/// <summary>
	/// The BlueGUI is a form class using the IInput interface through the object input
	/// </summary>
	public class BlueGUI : System.Windows.Forms.Form
	{
		IInput input;

		public BlueGUI(IInput input)
		{
			this.input = input;
			this.BackColor = System.Drawing.Color.Blue;
			this.Show();
		}
		
		public void GetInput()
		{
			this.Text = input.NotifyOutput();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Denmark Denmark
I am working as a software developer for COWI Engineers and Planners since year 2000, http://www.cowi.dk.

My main area of development is GIS (Geographical Information Systems) software using C# and Delphi with the mapping tools: MapXtreme 2004/MapBasic/MapInfo.


Comments and Discussions