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
Brandon Lewis
NA
527
126k
Casting String To Generic Type
Feb 28 2008 8:42 PM
I have a method which I want to look like this:
public static
T GetSetting<T>(
SettingKey
s key)
{
return
(T)settingList[key];
}
However, this will not compile of course but I hope you get the general idea :) I have a list of settings which need to be casted to certain data types based on what the setting is, and this generic method would be perfect if it would just work like this:
bool
sendingEmails = GetSetting<
bool
>(
SettingKeys
.IsSendingEmail);
If it were only so simple! Do you guys know of any clean work around for this? Thanks!
Reply
Answers (
1
)
Please help with these questions
Cant Get GetWindowLong To work