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 :: how to compare time strings in c# 
Csharp :: Severity Code Description Project File Line Suppression State Error MSB3021 
Csharp :: run in wpf 
Csharp :: how to get gravity from Rigidbody2D in c# 
Csharp :: c# move directory 
Csharp :: convert rgb to float 
Csharp :: wpf databinding 
Csharp :: how to check to see if the keyboard buttons are pressed in unity 
Csharp :: remove all values from list c# 
Csharp :: c# mysql select into datatable 
Csharp :: ef core add OnModelCreating foreign key 
Csharp :: docker-compose cassandra db 
Csharp :: reflection get enum value C# 
Csharp :: c# if else 
Csharp :: c# extension 
Csharp :: longest palindromic substring 
Csharp :: orderby c# 
Csharp :: c# convert datetime to timespan 
Csharp :: wpf dispatcher timer is inaccurate 
Csharp :: shuffle array c# 
Csharp :: how to make a C# game launcher 
Csharp :: c# check multiple variables for null 
Csharp :: SceneManagment by BuildIndex 
Csharp :: c# Least prime factor of numbers till n 
Csharp :: real world example of sinleton design pattern 
Csharp :: How to determine whether Task.Run is completed within a loop in c# 
Csharp :: remove starting 0 in astring C# 
Csharp :: select every second row in html table 
Csharp :: How to add a button to a column in the DataGridView 
Csharp :: f# print array strings 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =