Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,948 questions

51,890 answers

573 users

How to use interface with properties in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{

    interface Iinte
    {
        int iq { get; set; } // Property interface
        string user { get; set; } // Property interface
    }

    class Image : Iinte // Implements interface
    {
        public int iq // Property implementation
        {
            get;
            set;
        }

        string _user;

        public string user // Property implementation
        {
            get { return this._user; }
            set { this._user = value; }
        }
    }

    class Article : Iinte
    {
        public int iq 
        {
            get;
            set;
        }

        string _name;

        public string user 
        {
            get { return this._name; }
            set { this._name = value.ToUpper(); }
        }
    }


    class Program
    {
        static void Main(string[] args)
        {
            Iinte inte1 = new Image();
            Iinte inte2 = new Article();

            inte1.iq++; 
            inte2.iq += 13;

            inte1.user = "3-PO";
            inte2.user = "R2-D2"; 

            Console.WriteLine(inte1.user + " : " + inte1.iq); 
            Console.WriteLine(inte2.user + " : " + inte2.iq);
        }
    }
}


/*
run:
     
3-PO : 1
R2-D2 : 13
 
*/

 



answered Dec 21, 2016 by avibootz

Related questions

1 answer 192 views
192 views asked Sep 11, 2020 by avibootz
2 answers 219 views
219 views asked Apr 25, 2017 by avibootz
1 answer 126 views
126 views asked Dec 15, 2020 by avibootz
1 answer 167 views
1 answer 120 views
120 views asked Apr 25, 2017 by avibootz
1 answer 99 views
99 views asked Sep 11, 2020 by avibootz
1 answer 139 views
139 views asked Apr 27, 2017 by avibootz
...