Attempts to parse the string value as an Int32. - CSharp System

CSharp examples for System:String Parse

Description

Attempts to parse the string value as an Int32.

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Globalization;
using System.ComponentModel;
using System.Collections.Generic;
using System;// w  ww . j  a va 2 s  .  c  om

public class Main{
        /// <summary>
        /// Attempts to parse the string value as an Int32.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool CanParseInt32(this string value)
        {
            if (value == null) return false;

            int tmp;
            if (int.TryParse(value, out tmp)) return true;

            return false;
        }
}

Related Tutorials