Skip to content

Classes

IT Notes → C# @ December 22, 2020

  • Partial Classes and Methods.
  • Automatic Properties.
  • Reference to a base class can refer to an instance of a subclass.
  • An upcast operation creates a base class reference from a subclass reference.
  • A downcast operation creates a subclass reference from a base class reference. It has to be explicit.
  • The as operator performs a downcast that evaluates to null if the downcast fails.
  • The is operator tests whether a downcast would succeed.
  • Any abstract member forces the entire class to be abstract. So, no actual object instances of base class. It has empty implementation.
  • A function marked as virtual can be overridden by subclasses wanting to provide a specialized implementation.
  • Remember override and base.
  • From subclass to base class constructor arguments are evaluated and in reverse order constructor bodies execute.
  • In case of method overloading, when an overload is called, the most specific type has precedence. The particular overload to call is determined statically (at compile time) rather than dynamically (at runtime).
  • Accessibility internal by default for non-nested classes.
  • A subclass itself can be less accessible than a base class, but not more accessible.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x