C#

Check if clipboard is empty

Let’s see how we can check if the clipboard contains any data in C#:

IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
if (data == null)
{
    //no data
    //do stuff
}
else
{
    //data
    //do stuff
}