Hello, I don’t understand why the code I wrote is not accepted by the system:
/**************************************************/
using System;
namespace ParametersToMethods
{
class HowManyZer0s
{
static void Main()
{
string inputString = Console.ReadLine();
int numberOfZeros;
if (AnalyzeString(inputString, out numberOfZeros))
{
Console.WriteLine(numberOfZeros);
}
if (!AnalyzeString(inputString, out numberOfZeros))
{
Console.WriteLine("The string is invalid.");
}
}
static bool AnalyzeString(string input, out int zeros){
zeros = 0;
if (String.IsNullOrEmpty(input))
{
return false;
}
for (int i = 0; i < input.Length; i++)
{
if (input[i] == '0')
{
zeros++;
}
}
return true;
}
}
}
/**************************************************/
The console output is correct but the system just does not accept the solution for some reason.
thanks a lot