In C#, the interface can be instantiated?

前端 未结 7 2023
孤街浪徒
孤街浪徒 2021-01-20 21:29

I\'m reading the code in here. I find that private ITreeModel _model; in TreeList.cs:

namespace Aga.Controls.Tree
{
    public class TreeList: L         


        
7条回答
  •  情书的邮戳
    2021-01-20 21:39

    Of course you can do this, but underlying object must implement this Interface. So you can do something like

    ITreeModel _model  = new TreeModel();
    

    Where

    public class TreeModel:ITreeModel
    {
      ...
    }
    

提交回复
热议问题