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 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 :: viewresolver cyrillic 
Csharp :: c# use list as a paramter 
Csharp :: Remove tabpage by key 
Csharp :: enum extends dictionary c# 
Csharp :: filter collection viewbag 
Csharp :: death transition unity 2d 
Csharp :: small basic input 
Csharp :: Unable to Write json variable c# getting an error 
Csharp :: how to add multiple values in session in asp.net visual studio 
Csharp :: mac osx enable hidpi terminal 
Csharp :: c# compare char arrays 
Csharp :: c# plus one 
Csharp :: report background worker 
Csharp :: unity mass unit 
Csharp :: unity shader show object behind object 
Csharp :: C# verify "no other" call xunit 
Csharp :: ef null check 
Csharp :: how to get the size of an array in c# 
Csharp :: is it possible to be palindrome 
Csharp :: shallow copy vs deep copy c# 
Csharp :: protected override void OnExiting(Object sender, EventArgs args) { base.OnExiting(sender, args); Environment.Exit(Environment.ExitCode); } 
Csharp :: c# second last index 
Csharp :: c# get regedit value 
Csharp :: wie macht man eine schleife in c# 
Csharp :: c# an object on upper level cannot be added to an object 
Html :: html input integer and positive 
Html :: leading spaces html 
Html :: bootstrap Bootstrap link 
Html :: refresh button html 
Html :: html theme meta 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =