C# Classes / Objects / Inheritance Flashcards
What does overloading constructors mean?
Overloaded constructors enable objects of a class to be conveniently initialized in different ways. To overload constructors, simply provide multiple constructor declarations with different signatures.
What is the special use case for the this keyword to prevent code duplication for constructor overloading?
What is a common gotcha when dealing with constructors?
What is a constructor initializer?
: this(time.Hour, time.Minute, time.Second) { }
This is called a constructor initializer. Enables a class to reuse initialization code provided by a constructor, rather than defining similar code in another constructor.
What is the nameof operator?
It’s common to include in an exception’s error message a variable’s or property’s identifier. As of C# 6, you can instead use the nameof operator, which returns a stringrepresentation of the identifier enclosed in parentheses.
What is garbage collection and what are destructors?
What are readonly Instance variables?
When should you use readonly over const?
When to use const over readonly?
How do you auto implement getter property and readonly?
What is the object browser?
What is the object initializer syntax look like when there is no perfect constructor for your needs but the instance variables are there?
What is operator overloading?
You can create operators that work with objects of your own types — via a process called operator overloading. You can overload most operators!
What is a Struct and when should you use one over a class?
What would overloading an operator in a stuct look like?
What would overloading the - and * operators look like?
What can’t you do with a struct?
What keyword is used to overload operators?
Can you overload an operator method for two different types?