In C#, the interface can be instantiated?
c#, interface
Solution
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
{
...
}
Problem
I'm reading the code in here. I find that `private ITreeModel _model;` in TreeList.cs: ``` namespace Aga.Controls.Tree { public class TreeList: ListView { #region Properties //... private ITreeModel _model; public ITreeModel Model { //... } //... } } ``` and the ITreeModel is a interface in ITreeModel.cs: ``` namespace Aga.Controls.Tree { public interface ITreeModel { /// <summary> /// Get list of children of the specified parent /// </summary> IEnumerable GetChildren(object parent); /// <summary> /// returns wheather specified parent has any children or not. /// </summary> bool HasChildren(object parent); } } ``` the `_model` is a instantiated object? Edited: `TreeList.cs`: ``` namespace Aga.Controls.Tree { public class TreeList: ListView { #region Properties /// <summary> /// Internal collection of rows representing visible nodes, actually displayed in the ListView /// </summary> internal ObservableCollectionAdv<TreeNode> Rows { get; private set; } private ITreeModel _model; public ITreeModel Model { get { return _model; } set { if (_model != value) { _model = value; _root.Children.Clear(); Rows.Clear(); CreateChildrenNodes(_root); } } } private TreeNode _root; internal TreeNode Root { get { return _root; } } //.... } } ``` } Edited2: Somewhere: ``` public partial class RegistrySample : UserControl { public RegistrySample() { InitializeComponent(); _tree.Model = new RegistryModel(); } } ``` `class RegistryModel : ITreeModel`