Yes. Icon.ToBitmap draws an icon on a new Bitmap object, so itβs safe to delete it after that.
Edit:
It is interesting to note the Icon.ToBitmap () method in Reflector. I expected this to be a simple call to Graphics.DrawImage or Graphics.DrawIcon, but it is more involved. As long as this is possible, the function will make a copy of the icon image data copy instead, but it will return to calling Graphics.DrawImage or Graphics.DrawIcon if it cannot make the copy. Copying memory is much faster, so this is obviously the reason, but it makes the code much harder to read.
source share