c# - Type conversion and typeof -
After
I have made the following declaration in C #
Personal IDictionary & LT; ViewModelBase, Type & gt; _routingDictionary;
With the following method
navigate through public zeros & lt; TDestinationViewModel & gt; () Where TDestinationViewModel: ViewModelBase {// I wish to use something like des = _routingDictionary [typeof (TDestinationViewModel)]}
But it does not work and I get a compile error is
you can not convert from 'System.Type' 'GalaSoft the .MvvmLight.ViewModelBase'
the following are I can solve this by using
Navigate through public zeros & lt; TDestinationViewModel & gt; () Where TDestinationViewModel: ViewModelBase, New () {TDestinationViewModelDes = New TDestinationViewModel (); Type destination = _routingDictionary [dace]; }
While there is no better way to do this?
You have declared the other way dictionary that ViewModelBase
is an important and Type
should be in the form of a value
this should be
Private IDictionary. & Lt; Type, ViewModelBase & gt; _routingDictionary;
Who says that type
will be an important and will see ViewModelBase
as a value.
Comments
Post a Comment