Not sure why you would want to do this because the GC can move heap allocated objects around at any time, but you can do this:
unsafe
{
BaseClass baseClass = new();
BaseClass* ptr = &baseClass;
Console.WriteLine($"{(long)ptr:X}");
}
You need to enable
unsafe
code in your project properties and you're going to get a bunch of warnings about this, but the code will still compile and run.