Referencing child class variables of scriptable objects

Hello, I have a problem that I don’t know how to reference a child class variable.

I have a scriptable object parent class

public abstract class parentClass : ScriptableObject
{

}

and a child class of this parent class

public class childClass : parentClass
{
public int value;
}

I got a list of parentClass classes and I want to ask the parentClass if it is a childClass and if it is a childClass get the variable value from it. How to get a reference to the childClass variable?

Thanks

This is an Anti-pattern and a Code smell

But if you really want to do it:

List<parentClass> list;

void Start() {
  foreach (parentClass p in list) {
    if (p is childClass c) {
      print($"{c.name} is a childClass with value {c.value}");
    }
  }
}

Thanks, I found this then also as:

                    if (parentClass is childClass)
                    {
                        var a= parentClass as childClass;
                    a.childClassVariable...
                    }

I once coded with blueprints in the Unreal Engine and I think similar is used quite often with the “Cast to” a class to get its variables.

One extra question: is there a way to put the class type standing behind the “as” to the input variables in custom functions like:

public void FunctionName(int a, int b, class c)
{
var d = parentClass as c; //or typeof(c)
}