Ejercicio
Función IsNumber
Objetivo
Cree una función que indique si una cadena es un número intensor. Debe usarse así:
if (IsNumber ("1234"))
System.Console.WriteLine ("Es un valor numérico");
Código de Ejemplo
using System;
public class exercise124
{
public static bool IsNumber(string text)
{
for (int i = 0; i < text.Length; i++)
if (text[i] < '0') || (text[i] > '9')
return false;
return true;
}
public static void Main()
{
Console.WriteLine( IsNumber("12") );
}
}