-3

I actually learn c# and i stuck at this theme:

what does this mean: [Baseclass] [name] = new [Subclass]

i only understand that i can use that as a parameter like

    public void DoSomething(Book _book)
    {
        if (_book is PokemonBook)
        {
            Console.WriteLine("It's a Pokemon-Book!");
        }
        else
        {
            Console.WriteLine("idk");
        }
    }

but i dont understand this [Baseclass] [name] = new [Subclass], when do is use this and what does it do?

and yes, it's a stupid question

2 Answers2

2

You cannot do Subclass x = new BaseClass (even if you cast), But can do BaseClass x = new SubClass

This is essentially treating an instance of subclass as baseclass.

moral
  • 150
  • 1
  • 6
0

i think this link can help you to learn all about class

https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/inheritance

and dont ask some question like this other Guys Use negative Point and with negative point you cant ask your Question here... why negative Point ? Bcs you must first try little Improve You Skill then try find you Answer With Search in GooGle or this site then if you are not find your Answer you must Qustion here and try to Read Question Rule

you can learn C# in Microsoft Site Easy ( you can find many Simple Example ) then you can come here and read many many many Code and ask and Answer and you Grow Faster

i hope my answer help you and dont forgot learn about OOP