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

C#

 
GeneralRe: unresolved hashtable problem Pin
Som Shekhar25-Apr-10 0:33
Som Shekhar25-Apr-10 0:33 
GeneralRe: unresolved hashtable problem Pin
Jassim Rahma25-Apr-10 1:14
Jassim Rahma25-Apr-10 1:14 
GeneralRe: unresolved hashtable problem Pin
Som Shekhar25-Apr-10 1:25
Som Shekhar25-Apr-10 1:25 
GeneralRe: unresolved hashtable problem [modified] Pin
Jassim Rahma26-Apr-10 3:48
Jassim Rahma26-Apr-10 3:48 
GeneralRe: unresolved hashtable problem Pin
Som Shekhar26-Apr-10 3:54
Som Shekhar26-Apr-10 3:54 
GeneralRe: unresolved hashtable problem Pin
Jassim Rahma26-Apr-10 12:35
Jassim Rahma26-Apr-10 12:35 
GeneralRe: unresolved hashtable problem Pin
Som Shekhar26-Apr-10 17:41
Som Shekhar26-Apr-10 17:41 
QuestionVariable of type Pin
jabbawok20-Apr-10 10:18
jabbawok20-Apr-10 10:18 
How do you store a type in a variable?

Let's say I have the following base class, and a couple of derived classes:

public abstract class MyBase
{
    public abstract string Test();

}

public class class1: MyBase
{
    public override string Test()
    {
        return "Class1";
    }
}

public class class2 : MyBase
{
    public override string Test()
    {
        return "Class2";
    }
}

Now, I want to store the "types" of class1 and class2 in an array, so I can instance the classes, something like this:

MyArray[0] TmpClass1 = new MyArray[0];
MyArray[1] TmpClass2 = new MyArray[1];

Obviously this doesn't work. And I've tried using typeof() and System.Type to do this, but end up getting compiler errors no matter what I try.

So how is it done?
AnswerRe: Variable of type Pin
Anthony Mushrow20-Apr-10 10:31
professionalAnthony Mushrow20-Apr-10 10:31 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 10:37
jabbawok20-Apr-10 10:37 
AnswerRe: Variable of type Pin
Luc Pattyn20-Apr-10 10:34
sitebuilderLuc Pattyn20-Apr-10 10:34 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 10:54
jabbawok20-Apr-10 10:54 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 11:00
jabbawok20-Apr-10 11:00 
GeneralRe: Variable of type Pin
Luc Pattyn20-Apr-10 11:09
sitebuilderLuc Pattyn20-Apr-10 11:09 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 12:53
jabbawok20-Apr-10 12:53 
GeneralRe: Variable of type Pin
Luc Pattyn20-Apr-10 11:03
sitebuilderLuc Pattyn20-Apr-10 11:03 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 11:12
jabbawok20-Apr-10 11:12 
GeneralRe: Variable of type Pin
Luc Pattyn20-Apr-10 11:15
sitebuilderLuc Pattyn20-Apr-10 11:15 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 11:23
jabbawok20-Apr-10 11:23 
AnswerRe: Variable of type Pin
jabbawok20-Apr-10 12:56
jabbawok20-Apr-10 12:56 
AnswerRe: Variable of type Pin
AspDotNetDev20-Apr-10 13:04
protectorAspDotNetDev20-Apr-10 13:04 
GeneralRe: Variable of type Pin
jabbawok20-Apr-10 13:32
jabbawok20-Apr-10 13:32 
AnswerRe: Variable of type Pin
AspDotNetDev20-Apr-10 14:04
protectorAspDotNetDev20-Apr-10 14:04 
AnswerRe: Variable of type Pin
AspDotNetDev20-Apr-10 14:09
protectorAspDotNetDev20-Apr-10 14:09 
QuestionwebBrowser controll and post Pin
Ziga120-Apr-10 9:21
Ziga120-Apr-10 9:21 

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.