Virtual methods are methods that can be overridden in inheriting (derived) classes. By default, in .NET, methods are not virtual. In order to declare a method as virtual, we need to declare it using the keyword virtual, like so:
Posts Tagged ‘operators’
Virtual Methods
Sunday, December 8th, 2019Instantiation
Wednesday, April 26th, 2017I have explained a few times already that when we are dealing with objects, most of the times we are not working with the original class itself – the blueprint, but we are actually create copies of it called instances.… Read more
Return operator
Tuesday, April 18th, 2017In few of our previous lessons, we used functions – methods that not only can be called, perform some action, but also return a value to the caller – the piece of code that called them. You can imagine this as placing the returned value in the place where the function was invoked from.… Read more
Continue operator
Monday, January 16th, 2017In the last article, we spoke about the Break operator being used to immediately stop a loop and continue the execution with the statements that follow after the loop. The Continue operator works somehow in the same way, with the only difference that it will only make the execution skip the current iteration of the loop.… Read more
Break operator
Monday, January 16th, 2017The break operator is used whenever we want to end a loop immediately, even before ending its execution in a natural way. Whenever the Break operator is met, the execution of the loop is immediately stopped and the program continues executing the first instruction that follows after the loop.… Read more
Other operators
Friday, January 6th, 2017Aside of the operators I have enumerated so far, there are a few other operators that are either too simple, too rarely used or too unimportant to create additional posts for them.
The . (dot) operator. We’ve used it quite a lot so far (remember Console.WriteLine?).… Read more
Conditional (ternary) operator
Friday, January 6th, 2017Conditional operator is a bit harder to explain. It takes an expression which produces a Boolean result in order to determine which of two other expressions will be calculated and have its value returned as a result. Its sign is ?:… Read more
Assignment operators
Friday, January 6th, 2017This is the simplest operator of them all. It’s expressed simply by the equal (=) sign. Assignment operators are used to assign (give) a value to a variable.
They can also be used in cascade. Lets have a look at simple and cascaded assignment:
1 2 3 |
string name = "John Doe"; int x, y, z; x = y = z = 3; |
One very important thing to always remember is NOT to confuse the assignment operator = with the comparison operator == (a very common programming mistake).… Read more
Comparison operators
Friday, January 6th, 2017Another kind of operators we have enumerated are the comparison operators. As their name suggest, comparison operators are used to compare operands. There are 6 comparison operators:
Bitwise operators
Friday, January 6th, 2017Any programmer knows that computers can only process information represented by a series of binary numbers (1 and 0). This means that when we store the number 55 in memory of the computer, it actually stores a series of bits represented as 00110111.… Read more