Click here to Skip to main content
16,016,527 members
Home / Discussions / C#
   

C#

 
GeneralRe: Get Variable Type from String Pin
SledgeHammer018-Aug-12 7:44
SledgeHammer018-Aug-12 7:44 
GeneralRe: Get Variable Type from String Pin
eddieangel8-Aug-12 8:54
eddieangel8-Aug-12 8:54 
GeneralRe: Get Variable Type from String Pin
Pete O'Hanlon8-Aug-12 9:27
mvePete O'Hanlon8-Aug-12 9:27 
GeneralRe: Get Variable Type from String Pin
SledgeHammer018-Aug-12 9:32
SledgeHammer018-Aug-12 9:32 
GeneralRe: Get Variable Type from String Pin
SledgeHammer018-Aug-12 9:33
SledgeHammer018-Aug-12 9:33 
GeneralRe: Get Variable Type from String Pin
eddieangel8-Aug-12 13:24
eddieangel8-Aug-12 13:24 
GeneralRe: Get Variable Type from String Pin
SledgeHammer018-Aug-12 13:44
SledgeHammer018-Aug-12 13:44 
GeneralRe: Get Variable Type from String Pin
eddieangel9-Aug-12 6:46
eddieangel9-Aug-12 6:46 
I needed that and also:

C#
private void GoTo<T>(string viewModel, int claimId) where T: WorkspaceViewModel


However, this line:

C#
Type type = Type.GetType(viewModel);


That returns null so everything else falls apart. How does it get a type from a string name? And can I pull out the string? It seems redundant since I am already giving it the type.

I can use T here:

C#
var workspace = _mainWindow.Workspaces.FirstOrDefault(vm => vm is T);


and that gets rid of the need for type up until here:

C#
workspace = (T)Activator.CreateInstance(type, new object[] { claimId });


Ayudame.

Cheers, --EA

Incidentally, without the "where T: WorkspaceViewModel I get an error on the workspace = (T)Activator... line.
GeneralRe: Get Variable Type from String Pin
eddieangel9-Aug-12 6:55
eddieangel9-Aug-12 6:55 
GeneralRe: Get Variable Type from String Pin
SledgeHammer019-Aug-12 7:58
SledgeHammer019-Aug-12 7:58 
GeneralRe: Get Variable Type from String Pin
eddieangel9-Aug-12 8:02
eddieangel9-Aug-12 8:02 
GeneralRe: Get Variable Type from String Pin
Pete O'Hanlon7-Aug-12 22:27
mvePete O'Hanlon7-Aug-12 22:27 
GeneralRe: Get Variable Type from String Pin
eddieangel8-Aug-12 6:02
eddieangel8-Aug-12 6:02 
GeneralRe: Get Variable Type from String Pin
eddieangel8-Aug-12 6:42
eddieangel8-Aug-12 6:42 
GeneralRe: Get Variable Type from String Pin
Pete O'Hanlon8-Aug-12 7:31
mvePete O'Hanlon8-Aug-12 7:31 
QuestionFarsiLibrary Pin
amin_alexi7-Aug-12 2:02
amin_alexi7-Aug-12 2:02 
AnswerRe: FarsiLibrary Pin
Dave Kreskowiak7-Aug-12 2:11
mveDave Kreskowiak7-Aug-12 2:11 
QuestionVideo Recording from a DVR using EMGU or DirectShow C# Pin
Gertlaub26-Aug-12 23:26
Gertlaub26-Aug-12 23:26 
QuestionRe: Video Recording from a DVR using EMGU or DirectShow C# Pin
Eddy Vluggen6-Aug-12 23:34
professionalEddy Vluggen6-Aug-12 23:34 
QuestionDisplay ports details which are opened in a particular ip address Pin
sarang_k6-Aug-12 23:25
sarang_k6-Aug-12 23:25 
AnswerRe: Display ports details which are opened in a particular ip address Pin
Eddy Vluggen6-Aug-12 23:32
professionalEddy Vluggen6-Aug-12 23:32 
AnswerRe: Display ports details which are opened in a particular ip address Pin
sarang_k7-Aug-12 1:40
sarang_k7-Aug-12 1:40 
GeneralRe: Display ports details which are opened in a particular ip address Pin
Eddy Vluggen7-Aug-12 1:48
professionalEddy Vluggen7-Aug-12 1:48 
AnswerRe: Display ports details which are opened in a particular ip address Pin
Avrillavigne7-Aug-12 19:57
Avrillavigne7-Aug-12 19:57 
GeneralRe: Display ports details which are opened in a particular ip address Pin
Pete O'Hanlon8-Aug-12 0:30
mvePete O'Hanlon8-Aug-12 0:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.