Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

interface property implementation c#

using System;
interface IName
{
    string Name { get; set; }
}

class Employee : IName
{
    public string Name { get; set; }
}

class Company : IName
{
    private string _company { get; set; }
    public string Name
    {
        get
        {
            return _company;
        }
        set
        {
            _company = value;
        }   
    }
}

class Client
{
    static void Main(string[] args)
    {
        IName e = new Employee();
        e.Name = "Tim Bridges";

        IName c = new Company();
        c.Name = "Inforsoft";

        Console.WriteLine("{0} from {1}.", e.Name, c.Name);
        Console.ReadKey();
    }
}
/*output:
 Tim Bridges from Inforsoft.
 */
Comment

c# interface properties

public interface ISampleInterface
{
    // Property declaration:
    string Name
    {
        get;
        set;
    }
}
Comment

c# interface property

interface InterfaceExample
{
    int Number { get; set; }
}

class Example : InterfaceExample
{
	int num = 0;
	public int Number { get { return num; } set { num = value; } }
}
Comment

c# interface implementation

// C# program to demonstrate working of 
// interface
using System;
  
// A simple interface
interface inter1
{
    // method having only declaration 
    // not definition
    void display();
}
  
// A class that implements interface.
class testClass : inter1
{
      
    // providing the body part of function
    public void display()
    {
        Console.WriteLine("Sudo Placement GeeksforGeeks");
    }
  
    // Main Method
    public static void Main (String []args)
    {
          
        // Creating object
        testClass t = new testClass();
          
        // calling method
        t.display();
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# get all letters 
Csharp :: string.QueryString c# 
Csharp :: listbox1.remove item c# 
Csharp :: c# list add to list 
Csharp :: wpf keyboard press event 
Csharp :: how to redirect to another page in button clicked in asp.net c# index.cshtml 
Csharp :: bytes size c# 
Csharp :: serilog .net 6 
Csharp :: registry keys and values 
Csharp :: update table in C# 
Csharp :: c# create log file 
Csharp :: onmousedown() not working unity 
Csharp :: get key in dictionary c# 
Csharp :: list of function in c# 
Csharp :: Get unique id of Device 
Csharp :: get index brushes properties c# 
Csharp :: aspx receive variable from url 
Csharp :: C# one line method 
Csharp :: unity rotate around point 
Csharp :: unity inspector draw line 
Csharp :: speech 
Csharp :: #dictionery in c 
Csharp :: Formcollection asp.net form 
Csharp :: cant see my classes in inspector 
Csharp :: c# xunit theory classdata model 
Csharp :: c# string to binary 
Csharp :: letter to number converter c# 
Csharp :: c# get out of for loop 
Csharp :: mysql restore backup from multiple files 
Csharp :: check if multiple variables are null c# 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =