In C#, the interface can be instantiated?

前端 未结 7 1915
孤街浪徒
孤街浪徒 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:54

    _model is a member of TreeList and that means that you can create an instance of a class and then it will contain an instance of some class. for example

    _model = new TreeModel(); 
    

    will make _model contain an instance

    but you cannot do

    _model = new ITreeModel(); 
    

    because ITreeModel is and interface and you cannot create an instance of an interface

提交回复
热议问题