如何从给定的字符串实例化接口或类

时间:2017-07-21 05:55:58

标签: c# asp.net .net system.reflection

这是我调用的函数

this.ExecuteSQLProcedure("sp_GenerateInterface", new object[] { TableName });

上述功能的结果并存储在字符串变量

string tableInterface  = 

Public Class UserMaster
{
     Guid UserId { get; set; }
     string UserName { get; set; }
     Guid RoleId { get; set; }
     string FirstName { get; set; }
     string LastName { get; set; }
     Guid AddressId { get; set; }
     long ContactNumber { get; set; }
     string ProfilePicture { get; set; }
     bool? IsActive { get; set; }
     Guid? EntryBy { get; set; }
     DateTime? EntryDate { get; set; }
     Guid? UpdatedBy { get; set; }
     DateTime? UpdatedDate { get; set; }
     Guid? DeletedBy { get; set; }
     DateTime? DeletedDate { get; set; }
     string Email { get; set; }
     bool fnCheckContactNumberExists( long ContactNumber );
     bool fnCheckEmailExists( string Email );
     bool fnCheckUserExistsorNot( string LoginCredential );
     bool fnCheckUserNameAvailable( string UserName );
     bool fnCheckUserNameExists( string UserName );
     bool fnCheckUserStatus( string LoginCredntial );
     string fnGenerateFrenchiseNumber( );
     string fnGetFirstLastName( string LoginCredential );
     Guid fnGetUserId( string LoginCredential );
     void sp_AuthenticateLogin( string LoginCredential,  out string Message,  out string MessageType,  string Password );
     void sp_CreateUser( string City,  long ContactNumber,  string Email,  string FirstName,  string HouseNo,  string LandMark,  string Lane,  string LastName,  string LoginCredential,  out string Message,  out string MessageType,  string Password,  string Street,  string UserName );
}

现在我想实例化这个类,以便我可以在任何地方使用它

1 个答案:

答案 0 :(得分:0)

您无法初始化界面。您需要从此接口实现类。

class UserMaster : IUserMaster
 {
 //implementation of methods.
 }
what inmlements all the metods.

你需要制作转换器,才能为这个类赋值。 是因为你想让属性等于字符串的类?