class Derived: Base,Iinterface1,Iinterface2{
}
Is there a way to get a Derived reference from the IIinterface1 reference when a class like this is defined?
c#
I'm not sure what "reference" means, but
Iinterface1obj;
If you have an instance reference with an interface type such as , the Derived
type variable is
Derived=(Derived)obj;
as shown in .
Also, if you want type information dynamically, refer to the results of obj.GetType()
.
If you want to get Type
from Type
,
AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(a=>a.GetTypes())
.Where(t=>typeof(IInterface1).IsAssignableFrom(t))
You can search from Assembly.GetTypes
as shown in .
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
582 PHP ssh2_scp_send fails to send files as intended
918 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.