TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John
NA
3
0
Type as a variable
Dec 18 2009 9:12 AM
Does anyone know how to make this type of code work?
Type t = typeof(int); // can also be a user designed type
var x= new t(); // won't work!
Same sort of issue: given a MethodInfo, "mi" invoked on an object, the resultant is of type object and must be cast. This works:
int n = (int) mi.Invoke(someobject, null); n has correct value
This does not work:
Type t = typeof(int);
var n = (t) mi.Invoke(someobject, null);
Any idea on how to do this? It works in Delphi but I cannot port the code to C#!
Thanks!
Reply
Answers (
4
)
Adding Negative Numbers in c#
how draw this straight line between two usercontrol at runtime?