I have one doubt concerning c# method overloading and call resolution.
Let's suppose I have the following C# code:
enum MyEnum { Value1, Value2 }
public void test() {
method(0); // this calls method(MyEnum)
method(1); // this calls method(object)
}
public void method(object o) {
}
public void method(MyEnum e) {
}
Note that I know how to make it work but I would like to know why for one value of int (0) it calls one method and for another (1) it calls another. It sounds awkward since both values have the same type (int) but they are "linked" for different methods.
C is highly portable and is used for scripting system applications which form a major part of Windows, UNIX, and Linux operating system. C is a general-purpose programming language and can efficiently work on enterprise applications, games, graphics, and applications requiring calculations, etc.
%d is used to print decimal(integer) number ,while %c is used to print character . If you try to print a character with %d format the computer will print the ASCII code of the character.
The C programming language is so popular because it is known as the mother of all programming languages. This language is widely flexible to use memory management. C is the best option for system level programming language.
Literal 0
is implicitly convertible to any enum
type, which is a closer match than object
. Spec.
See, for example, these blog posts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With