I would like to write a common method which would check if a form is already open. If it is open then just activate it. Otherwise show it. Now my challenge is what type of parameter do I pass to the Test method?
private void Test(?? ??)
{
bool isFormOpen = false;
foreach (Form form in Application.OpenForms)
{
if (form is ??)
{
isFormOpen = true;
form.Activate();
}
}
if (!isFormOpen)
{
}
}
Thanks
Nishant
the way your code is written you need to pass
Typeof the respective Form class…An alternative is to use generice – see the answer from Heinzi for that.