Need to cast to an object without knowing what type the object is
Posted
by jle
on Stack Overflow
See other posts from Stack Overflow
or by jle
Published on 2010-04-22T10:01:23Z
Indexed on
2010/04/22
10:03 UTC
Read the original article
Hit count: 258
I am trying to dynamically load my authentication server type based on a setting. I am hung up on how to cast to a type when I don't know the type.
Type t = Type.GetType(WebConfigurationManager.AppSettings.Get("AuthenticationSvcImpl"));
IAuthenticationService authCli = Activator.CreateInstance(t);
return authCli.AuthenticateUser(login);
I know there is Convert.ChangeType(), but that just converts to an object...
© Stack Overflow or respective owner