19 Replies
Would
Constructors in the same class can be linked with each other via the keyword base
be correct?"linked with" is odd phrasing
they're already "linked" in the sense that Employee derives from Person
base
is a way to specifically access members of the base classmembers?
properties, fields, methods
methods and attributes = members?
aah
fields? hahah
protected string ssn = "444-55-6666";
is a fieldoh
In other languages, i’m assuming these are called variables?
as for constructors specifically, the most accurate i could make your statement would be
Constructors in the same class can call each other via the this keyword and can call constructors in the base class using the base keyword
they can be, it's not quite correct
i see "attributes" being a common name for them, but in C# that means something differenthmm
variables more refer to local variables inside a method or some executing piece of code
i was under the impression that classes had attributes and methods only?
technically correct
hence why UML class diagrams have them only
C# also has properties, which are syntax sugar for get/set methods
so what’s the difference between a field and a attribute?
haven’t used them too much yet
in C# an attribute is completely different, it's basically extra information you can put on a class or member
for example
other code can read these attributes and do stuff with them, like this one would tell a json serializer library what name to use for the property in the class's json representation
It was explained as defining a
person
. Where the attributes are information about a person such as age, name etc. e.g Int age = 2
and methods are stuff they can do or perform such as runningas for comparing to UML, a C# field is a UML attribute
i see
That does clarify it a bit. I’ll return tomorrow, eepy time
Thanks king 👑