beginner help
Hi so im new and i need to present in code this things:
Defining a class,
Field vs Property
Calling functions from the base class
Constructors
Static function
Static field
I know how to make few of them but still would be nice if you show me
15 Replies
it looks like a homework to do 👀
Not exactly a homework but yeah its school thing
Can i get help with it there ?
you will not learn if you just get the solution
what makes you struggle ?
The Field vs property and constructors the most
The calling functions from base all i struggle with is when should i use
base(something)
and when base.something
a property is a field with a getter/setter define
O okay now i get it so they have Like built in get and set methods
yeah
and for example if you want to tranform your instance of a class in json you need to have some properties cause it doesn't detect field
just use them all the time 😄
Okay
How about the constructors and base keyword
the contructor is a normal method but it return a new instance of your object and you have to call it like your class name
Okay and i can have many of them right
yeah you can have multiple constructors
Okay okay
Now this one
i've always used the base(x)
I don't really have exeperience with inheritance in c#
Oh okay
as I see the
base(something)
is only to call the parent constructor