C# help, overloading a method












0















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...










share|improve this question

























  • 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?

    – Dour High Arch
    Nov 25 '18 at 18:09











  • @DourHighArch This is a school assignment and i find it a little odd. My code works perfect and does what it is supposed to. But the last thing the assignment wants me to to is " The user should also be able to enter a zero(0) to randomly generate a temperature. If this happens, no value should be sent to the method, this can be solved by method overloading" So I guess if the user enters the number zero, a random temperature should be generated. The rest of my code consists of some if and else to get the user to enter the correct temperature.

    – Simon
    Nov 25 '18 at 18:20













  • @DourHighArch The reason for the int variable is because the assignment said it should be stored as an int first. For some reason.

    – Simon
    Nov 25 '18 at 18:26
















0















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...










share|improve this question

























  • 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?

    – Dour High Arch
    Nov 25 '18 at 18:09











  • @DourHighArch This is a school assignment and i find it a little odd. My code works perfect and does what it is supposed to. But the last thing the assignment wants me to to is " The user should also be able to enter a zero(0) to randomly generate a temperature. If this happens, no value should be sent to the method, this can be solved by method overloading" So I guess if the user enters the number zero, a random temperature should be generated. The rest of my code consists of some if and else to get the user to enter the correct temperature.

    – Simon
    Nov 25 '18 at 18:20













  • @DourHighArch The reason for the int variable is because the assignment said it should be stored as an int first. For some reason.

    – Simon
    Nov 25 '18 at 18:26














0












0








0








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...










share|improve this question
















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...







c# methods overloading






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 20:41









Klaus Gütter

2,40311321




2,40311321










asked Nov 25 '18 at 18:02









Simon Simon

12




12













  • 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?

    – Dour High Arch
    Nov 25 '18 at 18:09











  • @DourHighArch This is a school assignment and i find it a little odd. My code works perfect and does what it is supposed to. But the last thing the assignment wants me to to is " The user should also be able to enter a zero(0) to randomly generate a temperature. If this happens, no value should be sent to the method, this can be solved by method overloading" So I guess if the user enters the number zero, a random temperature should be generated. The rest of my code consists of some if and else to get the user to enter the correct temperature.

    – Simon
    Nov 25 '18 at 18:20













  • @DourHighArch The reason for the int variable is because the assignment said it should be stored as an int first. For some reason.

    – Simon
    Nov 25 '18 at 18:26



















  • 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?

    – Dour High Arch
    Nov 25 '18 at 18:09











  • @DourHighArch This is a school assignment and i find it a little odd. My code works perfect and does what it is supposed to. But the last thing the assignment wants me to to is " The user should also be able to enter a zero(0) to randomly generate a temperature. If this happens, no value should be sent to the method, this can be solved by method overloading" So I guess if the user enters the number zero, a random temperature should be generated. The rest of my code consists of some if and else to get the user to enter the correct temperature.

    – Simon
    Nov 25 '18 at 18:20













  • @DourHighArch The reason for the int variable is because the assignment said it should be stored as an int first. For some reason.

    – Simon
    Nov 25 '18 at 18:26

















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?

– Dour High Arch
Nov 25 '18 at 18:09





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?

– Dour High Arch
Nov 25 '18 at 18:09













@DourHighArch This is a school assignment and i find it a little odd. My code works perfect and does what it is supposed to. But the last thing the assignment wants me to to is " The user should also be able to enter a zero(0) to randomly generate a temperature. If this happens, no value should be sent to the method, this can be solved by method overloading" So I guess if the user enters the number zero, a random temperature should be generated. The rest of my code consists of some if and else to get the user to enter the correct temperature.

– Simon
Nov 25 '18 at 18:20







@DourHighArch This is a school assignment and i find it a little odd. My code works perfect and does what it is supposed to. But the last thing the assignment wants me to to is " The user should also be able to enter a zero(0) to randomly generate a temperature. If this happens, no value should be sent to the method, this can be solved by method overloading" So I guess if the user enters the number zero, a random temperature should be generated. The rest of my code consists of some if and else to get the user to enter the correct temperature.

– Simon
Nov 25 '18 at 18:20















@DourHighArch The reason for the int variable is because the assignment said it should be stored as an int first. For some reason.

– Simon
Nov 25 '18 at 18:26





@DourHighArch The reason for the int variable is because the assignment said it should be stored as an int first. For some reason.

– Simon
Nov 25 '18 at 18:26












3 Answers
3






active

oldest

votes


















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.



    static decimal FahrToCels ()
{
// Your code here
}





share|improve this answer































    0














    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'
    }


    This solves your requirement to use method overloading, event though I find it a bit odd.






    share|improve this answer































      0














      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.






      share|improve this answer
























      • Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

        – Simon
        Nov 25 '18 at 18:43













      • 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> }

        – Marty
        Nov 25 '18 at 18:46











      • Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

        – Simon
        Nov 25 '18 at 18:51













      • 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.

        – Marty
        Nov 25 '18 at 18:56











      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470336%2fc-sharp-help-overloading-a-method%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      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.



          static decimal FahrToCels ()
      {
      // Your code here
      }





      share|improve this answer




























        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.



            static decimal FahrToCels ()
        {
        // Your code here
        }





        share|improve this answer


























          1












          1








          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.



              static decimal FahrToCels ()
          {
          // Your code here
          }





          share|improve this answer













          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 ()
          {
          // Your code here
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 19:39









          MAO3J1m0OpMAO3J1m0Op

          135




          135

























              0














              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'
              }


              This solves your requirement to use method overloading, event though I find it a bit odd.






              share|improve this answer




























                0














                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'
                }


                This solves your requirement to use method overloading, event though I find it a bit odd.






                share|improve this answer


























                  0












                  0








                  0







                  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'
                  }


                  This solves your requirement to use method overloading, event though I find it a bit odd.






                  share|improve this answer













                  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'
                  }


                  This solves your requirement to use method overloading, event though I find it a bit odd.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 25 '18 at 18:31









                  Alexander PopeAlexander Pope

                  335416




                  335416























                      0














                      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.






                      share|improve this answer
























                      • Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

                        – Simon
                        Nov 25 '18 at 18:43













                      • 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> }

                        – Marty
                        Nov 25 '18 at 18:46











                      • Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

                        – Simon
                        Nov 25 '18 at 18:51













                      • 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.

                        – Marty
                        Nov 25 '18 at 18:56
















                      0














                      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.






                      share|improve this answer
























                      • Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

                        – Simon
                        Nov 25 '18 at 18:43













                      • 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> }

                        – Marty
                        Nov 25 '18 at 18:46











                      • Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

                        – Simon
                        Nov 25 '18 at 18:51













                      • 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.

                        – Marty
                        Nov 25 '18 at 18:56














                      0












                      0








                      0







                      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.






                      share|improve this answer













                      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.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 25 '18 at 18:32









                      MartyMarty

                      1846




                      1846













                      • Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

                        – Simon
                        Nov 25 '18 at 18:43













                      • 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> }

                        – Marty
                        Nov 25 '18 at 18:46











                      • Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

                        – Simon
                        Nov 25 '18 at 18:51













                      • 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.

                        – Marty
                        Nov 25 '18 at 18:56



















                      • Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

                        – Simon
                        Nov 25 '18 at 18:43













                      • 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> }

                        – Marty
                        Nov 25 '18 at 18:46











                      • Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

                        – Simon
                        Nov 25 '18 at 18:51













                      • 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.

                        – Marty
                        Nov 25 '18 at 18:56

















                      Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

                      – Simon
                      Nov 25 '18 at 18:43







                      Even if im a newbie in programming, im aware that the assignment is strange.... Yes, making a method that doesnt take any parameters is what it tells me I could do. But how do i create this? I know how to generate random numbers, but how do i call for the method when the user enters 0? Because as of now when entering zero, is converts to -17,8 degree celsius. If i were to use if-statements, where would i put it? Because of now it automatically uses the convertion method when entering any given number

                      – Simon
                      Nov 25 '18 at 18:43















                      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> }

                      – Marty
                      Nov 25 '18 at 18:46





                      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> }

                      – Marty
                      Nov 25 '18 at 18:46













                      Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

                      – Simon
                      Nov 25 '18 at 18:51







                      Yes that seems like a solution. But how would I first make it generate the random number that then continues to the convering method? I need to make a new method, that has a number generator and the converter in it I guess?

                      – Simon
                      Nov 25 '18 at 18:51















                      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.

                      – Marty
                      Nov 25 '18 at 18:56





                      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.

                      – Marty
                      Nov 25 '18 at 18:56


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470336%2fc-sharp-help-overloading-a-method%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks