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

Interfaces In Action

Rate me:
Please Sign up or sign in to vote.
4.48/5 (40 votes)
22 Apr 2012CPOL9 min read 58.1K   573   87  
A basic introduction to interfaces and their usage in development
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ActionInterfaces
{
    public class DivideAction : ICustomAction<int>
    {
        public string Name
        {
            get { return "Divide Action"; }
        }

        public string Description { get; set; }

        public int Execute( int val )
        {
            Console.WriteLine( "Name: {0} Value: {1}", Name, val );

            if ( val > 2 )
                return val / 2;
            else
                return val;
        }
    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I'm originally from the UK, I hail from Saddleworth (near Manchester). I moved to the US in 2007 and live with my wife and daughter in New Jersey.

I started late into software development and do as much learning as I can. I've been a developer for 10 years, starting with Business BASIC on DG/UX boxes, moving to do Windows Mobile development using .NET CF. My tool of choice is C#, however I'll pick at whatever language is good for the job.

I struggle to concentrate on one thing, so don't really learn a topic very well before moving on to the next. It's my aim to sort this out and learn more about C#, the language, the design and more importantly how to use it like the masters I see on this site.

Comments and Discussions