Specified object to convert the UInt 64. - CSharp System

CSharp examples for System:Converter

Description

Specified object to convert the UInt 64.

Demo Code


using System.Xml.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;// w w w.  j  a  v  a2s  . c o  m
using System.Globalization;
using System.Collections.Generic;
using System;

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

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

Related Tutorials