在泛型函数中创建实例

在泛型函数中创建实例

问题描述:

Hello Frnds,



我想初始化对象。我想为此创建通用函数。所以我调用它并传递类型参数并初始化对象



Hello Frnds,

I want to Initialize the object. and I want to create generic function for that. so I call thet and pass the type perameter and initialize the object

mainWindowViewModel.HideOtherScreens();
mainWindowViewModel.menu = new Menu() { DataContext = new MenuViewModel(_mainWindowViewModel) }; ;
mainWindowViewModel.menu.Visibility = Visibility.Visible;                mainWindowViewModel._perentWindow.maincanvas.Children.Add(mainWindowViewModel.menu);







我有这种类型许多视图模型中的代码,即类,但初始化对象是diffrunt,即菜单,所以我需要为此创建通用函数





can你帮帮我



先谢谢你




I have this type of code in many viewmodels i.e. classes but the initilizing object is diffrunt i.e. Menu here so I need to create generic function for this


can you help me

Thanks in Advance