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
Lui Wang
NA
5
942
How to pass vairable to class ?
Dec 17 2018 12:04 AM
I want run my code bellow,but it says that I can not use varialbe as type,how can I implement?
using
System;
using
System.Linq;
using
System.Reflection;
namespace
Mike.ConsoleApp
{
class
Program
{
static
void
Main(
string
[] args)
{
#region this is ok
Personal specifiedPersonal =
new
Personal();
Employee<Personal> employee =
new
Employee<Personal>();
employee.DoSth();
#endregion
#region this would be error
Assembly assmebly =
typeof
(Personal).GetTypeInfo().Assembly;
Type dynamicType = assmebly.ExportedTypes.Where(x => x.Name ==
"Personal"
).FirstOrDefault();
Employee<dynamicType> dynamicEmployee =
new
Employee<dynamicType>();
dynamicEmployee.DoSth();
#endregion
Console.ReadLine();
}
public
class
Personal
{
public
string
FirstName {
get
;
internal
set
; }
public
string
LastName {
get
;
internal
set
; }
}
public
class
Employee<TModel>
{
public
void
DoSth()
{
Console.WriteLine(
"Done !!!"
); ;
}
}
}
}
Reply
Answers (
2
)
When check in in tfs file it not included on project on sour
Api is not Working in Testing