I stumbled upon this method
Clipboard.GetDataObject()
It returns an IDataObject so I figured there (maybe) was already a Class implementing the IDataObject Interface in the .net framework, but how can I find it?
I stumbled upon this method
Clipboard.GetDataObject()
It returns an IDataObject so I figured there (maybe) was already a Class implementing the IDataObject Interface in the .net framework, but how can I find it?
The whole point of an interface is that you do not have to know a specific class. just use
IDataObject myData = Clipboard.GetDataObject();
If you need to find the derived types for IDataObject
inside Visual Studio, you can use the Object Browser (View -> Object Browser
).
Type "IDataObject
" to the search box and select the .NET Framework version you need from the "Browse" dropdown list.
Expand the results and you should see "Derived Types" folder which should give you an answer.
If you want to know the real object behind the interface you can use:
var obj = Clipboard.GetDataObject();
var str = obj.GetType().ToString();
//I tried in a Windows Forms project and the type behind it is "System.Windows.Forms.DataObject"
But it doesn't have much value in this case (i think). See @speising answer :)