Click here to Skip to main content
15,905,015 members
Home / Discussions / C#
   

C#

 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 21:20
PozzaVecia14-Feb-12 21:20 
AnswerRe: About Reflecting and generics Pin
AspDotNetDev14-Feb-12 21:49
protectorAspDotNetDev14-Feb-12 21:49 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 22:26
PozzaVecia14-Feb-12 22:26 
GeneralRe: About Reflecting and generics Pin
AspDotNetDev15-Feb-12 7:09
protectorAspDotNetDev15-Feb-12 7:09 
GeneralRe: About Reflecting and generics Pin
AspDotNetDev14-Feb-12 21:52
protectorAspDotNetDev14-Feb-12 21:52 
AnswerRe: About Reflecting and generics Pin
BobJanova14-Feb-12 23:20
BobJanova14-Feb-12 23:20 
GeneralRe: About Reflecting and generics Pin
PozzaVecia14-Feb-12 23:29
PozzaVecia14-Feb-12 23:29 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 0:50
BobJanova15-Feb-12 0:50 
You have not explained your problem. And you still haven't.

Here's the part you may not be getting. If AudiA8 is a Car (i.e. it inherits from Car, or implements ICar), then you can pass it to a method taking a car. That is, you can do
MyClass.SomeMethod(new AudiA8(), new ZXR());

... given
class AudiA8 : Car {
 ...
}

class ZXR : Moto {
 ...
}

and
class MyClass {
 static void SomeMethod(Car car, Moto moto){ ... }
}


You don't need any runtime shenanigans with MyClass to make that work. You can still do this even if you're creating the cars/motos at runtime:

Car CreateCar(string classname){
 return (Car)Activator.CreateInstance(classname);
}

Moto CreateMoto(string classname){
 return (Moto)Activator.CreateInstance(classname);
}

void DoSomething(){
 MyClass.SomeMethod(
    CreateCar("YourNamespace.Cars.AudiA8"), 
    CreateMoto("YourNamespace.Motos.ZXR")
 );
}

GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 1:24
PozzaVecia15-Feb-12 1:24 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 1:59
BobJanova15-Feb-12 1:59 
GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 2:30
PozzaVecia15-Feb-12 2:30 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 2:37
BobJanova15-Feb-12 2:37 
GeneralRe: About Reflecting and generics Pin
GParkings15-Feb-12 2:52
GParkings15-Feb-12 2:52 
GeneralRe: About Reflecting and generics Pin
GParkings15-Feb-12 2:54
GParkings15-Feb-12 2:54 
GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 3:09
PozzaVecia15-Feb-12 3:09 
GeneralRe: About Reflecting and generics Pin
GParkings15-Feb-12 3:25
GParkings15-Feb-12 3:25 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 3:40
BobJanova15-Feb-12 3:40 
GeneralRe: About Reflecting and generics Pin
PozzaVecia15-Feb-12 10:17
PozzaVecia15-Feb-12 10:17 
GeneralRe: About Reflecting and generics Pin
BobJanova15-Feb-12 21:57
BobJanova15-Feb-12 21:57 
GeneralRe: About Reflecting and generics Pin
PozzaVecia16-Feb-12 0:02
PozzaVecia16-Feb-12 0:02 
GeneralRe: About Reflecting and generics Pin
GParkings15-Feb-12 22:54
GParkings15-Feb-12 22:54 
GeneralRe: About Reflecting and generics Pin
PozzaVecia16-Feb-12 0:05
PozzaVecia16-Feb-12 0:05 
QuestionTeam Project Pin
tryharder14-Feb-12 10:23
tryharder14-Feb-12 10:23 
QuestionResponse.TransmitFile not working on local network Pin
Member 342693614-Feb-12 5:08
Member 342693614-Feb-12 5:08 
QuestionC# 2010 - Sql SMO Backup ? Pin
Paramu197314-Feb-12 4:20
Paramu197314-Feb-12 4:20 

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.