My question is simple, I have a Type input in the code below and I want to cast it to the Core class and get the Info
variable which is static. How can I access the static variable via type input?
private static bool Button(Type type)
{
if (type is Core core)
{
Debug.Log(core.Info); // Info is a static string in Core class...
}
}
Now I have the following error:
For Better Understanding This Question, Here I have a mother core class that gives the inherited classes as type to the Button input. Now it should read the static variable of my inputs.
public abstract class Core
{
public abstract string Info { get; }
}
public class CoreA : Core
{
public override string Info => "Core A Info";
}
public class CoreB : Core
{
public override string Info => "Core B Info";
}
public class SomeClass
{
private void MainStart()
{
Panel.Button(typeof(CoreB)); // type: "Core B Info"
}
}