Instanciar clase mediante string en c#

Así sería un ejemplo para instanciar una clase con base en un string:


string className = "Notification" + NotificationsType.Name;
            string namespaceName = "Notification.Application.Services.Implementation.";
            
INotificationSender notificationInstance = (INotificationSender)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(namespaceName + className);

Sean felices! :) Y siéntanse libres de opinar ;)

No hay comentarios:

Publicar un comentario