Specified object to convert the Int 64. - CSharp System

CSharp examples for System:Converter

Description

Specified object to convert the Int 64.

Demo Code


using System.Xml.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;//from   w ww  .j  a  v a 2  s.  c  om
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        /// <summary>
        /// Specified object to convert the Int 64.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="numberStyle"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        public static Int64? ToInt64(Object value, NumberStyles numberStyle, IFormatProvider formatProvider)
        {
            Int64 x;

            if (Int64.TryParse(ToStringOrEmpty(value), numberStyle, formatProvider, out x))
            {
                return x;
            }
            return null;
        }
        /// <summary>
        /// Specified object to convert the Int 64.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Int64? ToInt64(Object value)
        {
            return ToInt64(value, DefaultNumberStyle, null);
        }
        /// <summary>
        /// Specified object to convert the Int 64.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="defaultValue"></param>
        /// <param name="numberStyle"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        public static Int64 ToInt64(Object value, Int64 defaultValue, NumberStyles numberStyle, IFormatProvider formatProvider)
        {
            return ToInt64(value, numberStyle, formatProvider) ?? defaultValue;
        }
        /// <summary>
        /// Specified object to convert the Int 64.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static Int64 ToInt64(Object value, Int64 defaultValue)
        {
            return ToInt64(value) ?? defaultValue;
        }
}

Related Tutorials