0

Fill in the blanks to overload the greater than operator for the Box class. (C#)

public static .................. operator...... (Box a,Box b) { if (a.Height*a.Width > b.Height*b.Width) return true; else return false; }

9th Jan 2023, 11:42 AM
Katchi Mohamed Mohamed Hanan
Katchi Mohamed Mohamed Hanan - avatar
7 Respuestas
+ 1
public static bool operator > (Box a, Box b) { if (a.Height * a.Width > b.Height * b.Width) { return true; } else { return false; } }
9th Jan 2023, 7:46 PM
Aditya Dixit
+ 2
How is your question?
9th Jan 2023, 11:54 AM
JaScript
JaScript - avatar
+ 2
A hint for you, Katchi Mohamed Mohamed Hanan : When methods have the same name, but different parameters, it is known as method overloading. About overloading can be learnd here quite at the end of Java Tutorial in a part with „classes“. Additional you could look carefully on the method and think for example what will be there returned and what means that for the appearance of the method etc.
9th Jan 2023, 1:52 PM
JaScript
JaScript - avatar
+ 2
Now I see c#, but my answer is the same and as Ipang already said. Reading carefully again and try to code, this is the way.
9th Jan 2023, 6:56 PM
JaScript
JaScript - avatar
0
This is the question JaScript
9th Jan 2023, 1:16 PM
Katchi Mohamed Mohamed Hanan
Katchi Mohamed Mohamed Hanan - avatar
0
This is not java question it's c# JaScript
9th Jan 2023, 1:55 PM
Katchi Mohamed Mohamed Hanan
Katchi Mohamed Mohamed Hanan - avatar
0
When having difficulty in lesson quiz, it uaually helps to take a step back and re-read the relevant chapter. It's all there if we just look carefully. Yet again, it can't hurt to check the docs for more details, and examples https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/operator-overloading
9th Jan 2023, 3:53 PM
Ipang