[Solved] I need help in meeting a certain criteria for a function in C#


If I understand correctly:

private string FunctionWithTwoParameters(string name="", int count=0)
{
   if (count > 0)
   {
      for (int i = 0; i < count; i++)
      {
         name += name;                    
      }                
   }
   return name;
}

Such parameters of the method (string name="", int count=0) means that you can call the method with or without parameters

A little explanation:

“Write a function that Has two parameters.”:

FunctionWithTwoParameters(string name="", int count=0)

“Allows somebody to call the function with one argument being a name and the second being a number.”:

FunctionWithTwoParameters(string name="", int count=0)

This code allows to assign name and number respectively. Also such signature allows to call method with or without parameters.

“The function returns a string with the name repeated the number of times stated.”:

if (count > 0)
   {
      for (int i = 0; i < count; i++)
      {
         name += name;                    
      }                
   }
   return name;

The body of this method checks whether the number is positive value and if yes, then repeat the number of times stated

3

solved I need help in meeting a certain criteria for a function in C#