I have two forms: Form_Main and Form_Child and I have to instantiate Form_Child within Form_Main. Form main has a List and the constructor of Form_Child has a generic List. When I try to instantiate the child form, I get the following error message: Error 1 The non-generic type 'GenericParameterToFormConstructor.Form_Child' cannot be used with type arguments. The code of form_Main is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GenericParameterToFormConstructor
{
public partial class Form_Main : Form
{
public Form_Main()
{
InitializeComponent();
_list = new List<int>() { 1, 2, 3, 4, 5 };
Form_Child child = new Form_Child<int>(_list);
}
private List<int> _list;
}
}
The code of Form_Child is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GenericParameterToFormConstructor
{
public partial class Form_Child<T> : Form
{
public Form_Child(List<T> list)
{
InitializeComponent();
}
}
}
What am I doing wrong? Please help. Thank you in advance.