Click here to Skip to main content
15,921,276 members
Home / Discussions / C#
   

C#

 
Generaldeactivate the possibility to connect a usb-device Pin
mcyrrer7-Apr-05 4:12
mcyrrer7-Apr-05 4:12 
GeneralRe: deactivate the possibility to connect a usb-device Pin
Dave Kreskowiak7-Apr-05 4:58
mveDave Kreskowiak7-Apr-05 4:58 
GeneralShell parameters - get them Pin
Seraphin7-Apr-05 3:48
Seraphin7-Apr-05 3:48 
GeneralRe: Shell parameters - get them Pin
hooray7-Apr-05 4:06
hooray7-Apr-05 4:06 
Generalable in sqlInserting into SQL server Pin
cmitty7-Apr-05 3:46
cmitty7-Apr-05 3:46 
GeneralCreating objects at Runtime Pin
NeoPolaris7-Apr-05 2:54
NeoPolaris7-Apr-05 2:54 
GeneralRe: Creating objects at Runtime Pin
Ryan Roberts7-Apr-05 3:41
Ryan Roberts7-Apr-05 3:41 
GeneralRe: Creating objects at Runtime Pin
mav.northwind7-Apr-05 8:40
mav.northwind7-Apr-05 8:40 
That's exactly the way to go.

You just have to know the fully qualified type name of the class you want to create, otherwise the framework doesn't know which type to create.

For example, you can do this:
string typeToCreateName = "System.Drawing.Font, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
Type typeToCreate = Type.GetType(typeToCreateName);
object o = Activator.CreateInstance(typeToCreate);
There are two pitfalls, though:
First, determining the fully qualified type name can be a bit tricky.
Secondly, the type you want to create has to have a parameterless constructor. The example above will fail, because Font doesn't have such a constructor.

Mav
GeneralRe: Creating objects at Runtime Pin
Ashok Dhamija7-Apr-05 3:42
Ashok Dhamija7-Apr-05 3:42 
GeneralRe: Creating objects at Runtime Pin
J4amieC7-Apr-05 4:26
J4amieC7-Apr-05 4:26 
GeneralRe: Creating objects at Runtime Pin
Dave Kreskowiak7-Apr-05 4:55
mveDave Kreskowiak7-Apr-05 4:55 
GeneralRe: Creating objects at Runtime Pin
Ashok Dhamija7-Apr-05 17:45
Ashok Dhamija7-Apr-05 17:45 
Generalcombobox in sourcegrid2 Pin
nisrina7-Apr-05 2:26
nisrina7-Apr-05 2:26 
GeneralSerial Port(Framework2.0) Pin
Snowjim7-Apr-05 1:54
Snowjim7-Apr-05 1:54 
QuestionStreams? Pin
Snowjim7-Apr-05 1:50
Snowjim7-Apr-05 1:50 
QuestionHow do i make it so the app runs without having .net installed? Pin
Anthony Mushrow7-Apr-05 0:46
professionalAnthony Mushrow7-Apr-05 0:46 
AnswerSearch the forums Pin
mav.northwind7-Apr-05 0:52
mav.northwind7-Apr-05 0:52 
GeneralRe: Search the forums Pin
Michael P Butler7-Apr-05 3:26
Michael P Butler7-Apr-05 3:26 
GeneralRe: Search the forums Pin
Luis Alonso Ramos7-Apr-05 7:30
Luis Alonso Ramos7-Apr-05 7:30 
AnswerRe: How do i make it so the app runs without having .net installed? Pin
Colin Angus Mackay7-Apr-05 3:40
Colin Angus Mackay7-Apr-05 3:40 
AnswerRe: How do i make it so the app runs without having .net installed? Pin
Dave Kreskowiak7-Apr-05 4:49
mveDave Kreskowiak7-Apr-05 4:49 
Generalc# express and database Pin
Anonymous6-Apr-05 22:50
Anonymous6-Apr-05 22:50 
GeneralCreate,convert datetime in C#,ASP.NET Pin
hvan22036-Apr-05 22:40
hvan22036-Apr-05 22:40 
GeneralRe: Create,convert datetime in C#,ASP.NET Pin
hooray7-Apr-05 1:54
hooray7-Apr-05 1:54 
QuestionHow do i stop people resizing my window??? Pin
Anthony Mushrow6-Apr-05 22:26
professionalAnthony Mushrow6-Apr-05 22:26 

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.