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

PREVIOUS NEXT
Code Example
Csharp :: c# HttpResponseMessage postResponse = client.PostAsync 
Csharp :: c# return values 
Csharp :: escape in c# 
Csharp :: dbset 
Csharp :: implicit vs explicit cast c# 
Csharp :: Default property value in C# 
Csharp :: remove control characters from string c# 
Csharp :: *ngif vs ngif 
Csharp :: triangle 
Csharp :: symfony debug bar 
Csharp :: c# code snippets 
Csharp :: while loop in c# 
Csharp :: C# date type no time 
Csharp :: cloudmailin c# 
Csharp :: unity color mix 
Csharp :: create anchor tag dynamically c# 
Csharp :: index list c# 
Csharp :: O thread de chamada não pode aceder a este objecto porque existe outro thread que já o tem 
Csharp :: how to hide cell in epplus 
Csharp :: html inside razor 
Csharp :: how to assign 2d physics material through script 
Csharp :: entity framework dynamic search solution 1 
Csharp :: Toggle value change 
Csharp :: mailkit send email c# 
Csharp :: c# Showing a hidden WPF window 
Csharp :: fetch post .net 
Csharp :: json.net jobject replace value 
Csharp :: virtual list entity framework 
Csharp :: quartz .net core execute controller 
Csharp :: c# message box carriage return 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =