I have a few dialogs in my class and I'm trying to initialize them with a function:
private void InitializeFileDialog(ref FileDialog fileDialog)
{
fileDialog.Filter = "Word Documents|*.doc|Excel Worksheets|*.xls|PowerPoint Presentations|*.ppt" +
"|Office Files|*.doc;*.xls;*.ppt" +
"|All Files|*.*";
fileDialog.DefaultExt = "txt";
}
The problem is when I call it:
InitializeFileDialog(ref dialog);
error CS1503: Argument 1: cannot convert from 'ref Microsoft.Win32.OpenFileDialog' to 'ref Microsoft.Win32.FileDialog'
I tried to cast, but it couldn't for some reason. What's the problem? Is it because FileDialog
is abstract? I tried to look up if that's the reason but I couldn't find anything useful.
Here are the declarations that are found in Microsoft.Win32
:
public abstract class FileDialog : CommonDialog
public sealed class OpenFileDialog : FileDialog
I also tried to use generics and it didn't work. What am I missing?