Click here to Skip to main content
15,904,926 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a form1.cs
where in i need to have some template List
IList<mytemplate> list;
</mytemplate>


and i need to use the above list variable in lot of places

but i cannot have a template creation in class level
like
public class Form1<mytemplate>where MyTemlate:TemplateBase</mytemplate>

because my Form1 Class is already inheriting Form base class


Please advise how to use template in Form
Posted

1 solution

You can create a static class and make your template a public data member of the class.

C#
public TemplateList : IList<mytemplate>;

public static class Globals
{
    private static m_templates = new TemplayteList();
    public static Templates { get; private set;}
}</mytemplate>


Now, you can use it anywhere in your application.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900