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



这是我调用的函数

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 );
}

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

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

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

并且您需要制作转换器,以便能够为此类分配值。 因为您想拥有属性等于字符串的类?

最新更新