Interfaces in c#

namespace CSharpBasics
{
    interface interface1
    {
        //int i = 0;  Error - Interfaces cannot contain variables

        //Default access specifier in interface is PUBLIC
        string s_method();

        //int i_method() ERROR - Interfaces cannot have function definations
        //{
        //    return 1;
        //}

        string name //Interfaces can have Properties
        {
            get;
        }
    }

    class inter_class : interface1
    {
        #region interface1 Members

        string interface1.s_method()
        {
            //throw new Exception("The method or operation is not implemented.");
            return "duumy text";
        }

        string interface1.name
        {
            get 
            {
                //throw new Exception("The method or operation is not implemented."); 
                return "duumy text";
            }
        }

        #endregion
    }
}
Add Comments :

Login

Register