CSharp examples for System:Converter
Specified object to convert the Int 16.
using System.Xml.Serialization; using System.Text.RegularExpressions; using System.Text; using System.IO;/*from ww w.j a va 2 s. co m*/ using System.Globalization; using System.Collections.Generic; using System; public class Main{ /// <summary> /// Specified object to convert the Int 16. /// </summary> /// <param name="value"></param> /// <param name="numberStyle"></param> /// <param name="formatProvider"></param> /// <returns></returns> public static Int16? ToInt16(Object value, NumberStyles numberStyle, IFormatProvider formatProvider) { Int16 x; if (Int16.TryParse(ToStringOrEmpty(value), numberStyle, formatProvider, out x)) { return x; } return null; } /// <summary> /// Specified object to convert the Int 16. /// </summary> /// <param name="value"></param> /// <returns></returns> public static Int16? ToInt16(Object value) { return ToInt16(value, DefaultNumberStyle, null); } /// <summary> /// Specified object to convert the Int 16. /// </summary> /// <param name="value"></param> /// <param name="defaultValue"></param> /// <param name="numberStyle"></param> /// <param name="formatProvider"></param> /// <returns></returns> public static Int16 ToInt16(Object value, Int16 defaultValue, NumberStyles numberStyle, IFormatProvider formatProvider) { return ToInt16(value, numberStyle, formatProvider) ?? defaultValue; } /// <summary> /// Specified object to convert the Int 16. /// </summary> /// <param name="value"></param> /// <param name="defaultValue"></param> /// <returns></returns> public static Int16 ToInt16(Object value, Int16 defaultValue) { return ToInt16(value) ?? defaultValue; } }