Monday, May 3, 2021

C# Char class GetNumericValue method

C# Char class GetNumericValue method


using System;

namespace ConsoleGetNumericValue
{
    class Program
    {
        static void Main(string[] args)
        {
            //characters of string must be numerals else Char.GetNumericValue(myname, i) will return -1
            string myname = "ajeet2019kumar56";
            for (int i = 0; i < myname.Length; i++)
            {
                double d = Char.GetNumericValue(myname, i);
                if (d != -1)
                {
                    Console.Write(d);
                }
            }
            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment

Hot Topics