create interface from class c# code example

Example 1: c# interface properties

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

Example 2: creating interface in C#

using System;

namespace Grepper_Docs
{
    public interface IWhatever
    {
        bool doSomething(); //Interface methods don't have bodies or modifiers
    }
  
  	class Program : IWhatever
    {
        static void Main(string[] args)
        {
            var pro = new Program();
            pro.doSomething();
        }

        public bool doSomething() //methods must be public
        {
            return true;
        }
    }
}