what is method overriding in c#

I have one last thing to add to my assignment before im finished.

This is a part of my code:

```static decimal FahrToCels(int fahrenheit) //Metod för konvertering av Fahrenheit(F) till Celsius(C)
{
decimal celsius = (decimal)((fahrenheit - 32) * 5) / 9; // Matematisk uträkning för F till C.
return Math.Round (celsius, 1); //Lagrar ett decimal tal avrundat till 1 decimal och lagrar i celsius
}

static void Main(string[] args)
{
Console.Write("Vänligen ange temperatur till bastun och tryck enter: "); //skriver ut meddelande

do
int fahr = int.Parse(Console.ReadLine()); // Omvandlar string och lagrar användarens inmatning i en int fahrenheit
decimal celsius = FahrToCels(fahr); // Metoden FahrToCels konverterar inmatad temperatur till celsius och lagrar i decimal celsius
```

As can be seen, ive created a method, that is later used after the user is told to enter degrees in fahrenheit. The method converts the entered number to celsius.

Now the last thing im told to do is by overloading the method, make it possible for the user to enter zero(0) and by doing that randomly generate a number before that number goes into the fahrenheit to celsius converting method. Im guessing the generated numbet has to be like between 140-195 because the user needs to enter zero until the generated number equals to 73-77 after converting to celsius!

I know how to generate a random number, and i think i understand what overloading does, but im totally lost on how to do this one...

An idea would be to create a function under (or over) the method inside the class that takes no arguments. Nothing else special is required. When you want to call `FahrToCels()`, you have the option to call either method based on the type and quantity of the arguments.

```    static decimal FahrToCels ()
{
}
```

C# Method Overloading, Method Overloading. With method overloading, multiple methods can have the same name with different parameters: Example. int MyMethod  1. An idea would be to create a function under (or over) the method inside the class that takes no arguments. Nothing else special is required. When you want to call FahrToCels (), you have the option to call either method based on the type and quantity of the arguments.

Create a new method like this

```    static decimal FahrToCels(string value) //note value is of type 'string'
{
//your implementation goes here, check if value is 'zero'
}
```

Overloading, In each example, I'll give a short program which will declare some methods and call one - and then I'll explain what gets called in which version of C#, and why. With method overloading, multiple methods can have the same name with different parameters: Example int MyMethod(int x) float MyMethod(float x) double MyMethod(double x, double y)

Apart from other possible concerns: Overloading a method has nothing to do with specific parameter values (unless you are using different types, e.g. short, int, long). In your case: "if the parameter value is 0 then return a random number" is not something solvable by overloading.

Now after reading your comment on the question; you could create a method that doesn't take any parameters `static decimal FahrToCels()` and call that in case you read a `0` from the input. This new method would then generate a random value and convert that.

Personal opinion: I'm not gonna comment on how reasonable that assignment is. The more standard case would be to use an `if` statement to decide if the input was `0` and if so generate a random value and pass that to the method you already have. But I might be missing something here.

Method overloading, Method overloading. A lot of programming languages support a technique called default/optional parameters. It allows the programmer to make one or several  In C#, we can overload constructors, methods and index properties since they have parameters defined in their signature. C# Method overloading: In a class, if we defined two methods with the same name but different signature then it’s called method overloading.

Member Overloading, For example, in the following, the WriteLine method is overloaded: C# Copy. public static class Console { public void WriteLine(); public void  What is Method Overloading or Function Overloading in C#? It is a process of creating multiple methods in a class with the same name but with a different signature. In C#, It is also possible to overload the methods in the derived classes, it means, it allows us to create a method in the derived class with the same name as the method name defined in the base class.

• `float` is a better choice than `int` or `double` for continuous quantities like temperature. Also, please give us an example of what "to enter zero" means. You know that zero is a perfectly valid temperature, right?
• you would need an `if` stament (that's why I was questioning the assignment). so it would be something like: `if(fahr == 0) { <call method without params> } else { <call the regular method> }`
• One possibility would be: generate the random number (either with or without an extra method) and use it as a parameter for calling the other `FahrToCels` method. Then return what you get from that.