• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NumberStyles类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NumberStyles的典型用法代码示例。如果您正苦于以下问题:C# NumberStyles类的具体用法?C# NumberStyles怎么用?C# NumberStyles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NumberStyles类属于命名空间,在下文中一共展示了NumberStyles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Parse

		public static int Parse(string s, NumberStyles style)
		{
			if (style == NumberStyles.HexNumber)
				return Native.API.intval(s, 16);

			return Native.API.intval(s);
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:7,代码来源:Int32.cs


示例2: Parse

	public static ulong Parse(String s, NumberStyles style,
							  IFormatProvider provider)
			{
				NumberParser.ValidateIntegerStyle(style);
				return NumberParser.ParseUInt64
					(s, style, NumberFormatInfo.GetInstance(provider), 0);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:UInt64.cs


示例3: TryParse

        public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out sbyte result)
        {
            // Todo, consider how to implemente style and provider
            throw new NotImplementedException();

            //return TryParse(s, out result);
        }
开发者ID:Orvid,项目名称:Cosmos,代码行数:7,代码来源:GeneralIntegerImpl.cs


示例4: Parse

	// Parsing methods.
	public static byte Parse(String s, NumberStyles style,
							 IFormatProvider provider)
			{
				NumberParser.ValidateIntegerStyle(style);
				return Convert.ToByte(NumberParser.ParseUInt32
					(s, style, NumberFormatInfo.GetInstance(provider), 256));
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:Byte.cs


示例5: ccParseInt

 /// <summary>
 /// Parses aint value for the given string using the given number style and using
 /// the invariant culture parser.
 /// </summary>
 /// <param name="toParse">The value to parse.</param>
 /// <param name="ns">The number style used to parse the int value.</param>
 /// <returns>The int value of the string.</returns>
 public static int ccParseInt(string toParse, NumberStyles ns)
 {
     // http://www.cocos2d-x.org/boards/17/topics/11690
     // Issue #17
     // https://github.com/cocos2d/cocos2d-x-for-xna/issues/17
     return (int.Parse(toParse, ns, System.Globalization.CultureInfo.InvariantCulture));
 }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:14,代码来源:ccUtils.cs


示例6: CheckStyle

		private static bool CheckStyle(NumberStyles style, bool tryParse, ref Exception exc)
		{
			if ((style & NumberStyles.AllowHexSpecifier) != 0)
			{
				NumberStyles ne = style ^ NumberStyles.AllowHexSpecifier;
				if ((ne & NumberStyles.AllowLeadingWhite) != 0)
				{
					ne ^= NumberStyles.AllowLeadingWhite;
				}
				if ((ne & NumberStyles.AllowTrailingWhite) != 0)
				{
					ne ^= NumberStyles.AllowTrailingWhite;
				}
				if (ne != 0)
				{
					if (!tryParse)
					{
						exc = new ArgumentException(
							"With AllowHexSpecifier only " +
							"AllowLeadingWhite and AllowTrailingWhite " +
							"are permitted.");
					}
					return false;
				}
			}

			return true;
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:28,代码来源:ParseHelper.cs


示例7: Parse

	// Parsing methods.
	public static short Parse(String s, NumberStyles style,
							  IFormatProvider provider)
			{
				NumberParser.ValidateIntegerStyle(style);
				return Convert.ToInt16(NumberParser.ParseInt32
					(s, style, NumberFormatInfo.GetInstance(provider), 32768));
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:Int16.cs


示例8: TryParseDecimal

        /// <summary>
        /// Tries to convert a string representation into a numeric value.
        /// </summary>
        public static bool TryParseDecimal(string s, NumberStyles style, out decimal result)
        {
#if PocketPC
            try
            {
                result = decimal.Parse(s, style, CultureInfo.InvariantCulture);
                return true;
            }
            catch (ArgumentException)
            {
                result = Decimal.Zero;
                return false;
            }
            catch (FormatException)
            {
                result = Decimal.Zero;
                return false;
            }
            catch (OverflowException)
            {
                result = Decimal.Zero;
                return false;
            }

#else
            return decimal.TryParse(s, style, CultureInfo.InvariantCulture, out result);
#endif
        }
开发者ID:phofman,项目名称:codetitans-libs,代码行数:31,代码来源:NumericHelper.cs


示例9: IsNumeric

 public static bool IsNumeric(this string text, NumberStyles style = NumberStyles.Number, CultureInfo culture = null)
 {
     double number;
     if (culture == null)
         culture = CultureInfo.InvariantCulture;
     return double.TryParse(text, style, culture, out number) && !string.IsNullOrWhiteSpace(text);
 }
开发者ID:plapisz,项目名称:WPFDatabaseApp,代码行数:7,代码来源:StringExtensions.cs


示例10: ParseTest

 public ParseTest(String str, Decimal d, NumberStyles style)
 {
     this.str = str;
     this.exceptionFlag = false;
     this.style = style;
     this.d = d;
 }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:DecimalTest.cs


示例11: InitializeMembers

 private void InitializeMembers()
 {
     this.encoding = null;
     this.culture = null;
     this.numberStyle = NumberStyles.Float;
     this.dateTimeStyle = DateTimeStyles.None;
 }
开发者ID:horvatferi,项目名称:graywulf,代码行数:7,代码来源:FormattedDataFile.cs


示例12: ConvertToNumeric

 public static Double ConvertToNumeric(object value, IFormatProvider provider, NumberStyles style)
 {
     var parsableString = value as String;
     if (parsableString == null)
     {
         var formatter = value as IFormattable;
         if (formatter != null)
         {
             string format = GeneralFormatter;
             if (formatter is Single || formatter is Double)
             {
                 format = RoundtripFormatter;
             }
             parsableString = formatter.ToString(format, provider);
         }
     }
     if (parsableString != null)
     {
         Double number;
         if (Double.TryParse(parsableString, style, provider, out number))
         {
             return number;
         }
     }
     throw new FormatException(Resources.Converter_Value_cant_be_parsed_to_numeric);
 }
开发者ID:VisualFinance,项目名称:VisualFinance.Windows,代码行数:26,代码来源:NumericConverterBase.cs


示例13: Parse

        /// <summary>Converts the string representation of a money value to its <see cref="Money"/> equivalent.</summary>
        /// <param name="value">The string representation of the number to convert.</param>
        /// <param name="style">A bitwise combination of enumeration values that indicates the permitted format of value. A typical value to specify is <see cref="NumberStyles.Currency"/>.</param>
        /// <param name="provider">An object that supplies culture-specific parsing information about <i>value</i>.</param>
        /// <param name="currency">The currency to use for parsing the string representation.</param>
        /// <returns>The equivalent to the money amount contained in <i>value</i>.</returns>
        /// <exception cref="System.ArgumentNullException"><i>value</i> is <b>null</b> or empty.</exception> 
        /// <exception cref="System.FormatException"><i>value</i> is not in the correct format or the currency sign matches with multiple known currencies!</exception>
        /// <exception cref="System.OverflowException"><i>value</i> represents a number less than <see cref="Decimal.MinValue"/> or greater than <see cref="Decimal.MaxValue"/>.</exception>
        public static Money Parse(string value, NumberStyles style, IFormatProvider provider, Currency currency)
        {
            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentNullException(nameof(value));

            decimal amount = decimal.Parse(value, style, GetNumberFormatInfo(currency, provider));
            return new Money(amount, currency);
        }
开发者ID:JayT82,项目名称:NodaMoney-1,代码行数:17,代码来源:Money.Parsable.cs


示例14: CsvColumnAttribute

 public CsvColumnAttribute(string name, int fieldIndex, bool canBeNull,
             string outputFormat, NumberStyles numberStyle, int charLength)
     : base(name, fieldIndex, canBeNull)
 {
     NumberStyle = numberStyle;
     OutputFormat = outputFormat;
     CharLength = charLength;
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:8,代码来源:CsvColumnAttribute.cs


示例15: Parse

 /// <summary>
 ///   Mono does not support the BigInteger.TryParse method. In practice,
 ///   we seldom actually need to parse huge integers, so it makes sense
 ///   to support most real-life cases by simply trying to parse using
 ///   Int64, and only falling back if needed.
 /// </summary>
 internal static BigInteger Parse(string str, NumberStyles style) {
     UInt64 parsed;
     if (UInt64.TryParse(str, style, NumberFormatInfo.CurrentInfo, out parsed)) {
         return new BigInteger(parsed);
     } else {
         // Throws on Mono 3.2.8
         return BigInteger.Parse(str, style);
     }
 }
开发者ID:Chris-Hawblitzel,项目名称:dafny,代码行数:15,代码来源:BigIntegerParser.cs


示例16: ToSByteOrDefault

		public static sbyte ToSByteOrDefault(this string s, NumberStyles numberStyles, IFormatProvider formatProvider, sbyte defaultValue = default(sbyte))
		{
			sbyte result;
			if(sbyte.TryParse(s,numberStyles, formatProvider, out result))
			{
				return result;
			}
			return defaultValue;
		}
开发者ID:pierre3,项目名称:HandyUtilities.Xsv,代码行数:9,代码来源:StringExt.t4.cs


示例17: ToSByteOrNull

		public static sbyte? ToSByteOrNull(this string s, NumberStyles numberStyles)
		{
			sbyte result;
			if(sbyte.TryParse(s, numberStyles, null, out result))
			{
				return result;
			}
			return null;
		}
开发者ID:pierre3,项目名称:HandyUtilities.Xsv,代码行数:9,代码来源:StringExt.t4.cs


示例18: UnparsedNumber

        public UnparsedNumber(string value, Type type, NumberStyles numberStyles)
        {
            Require.NotEmpty(value, "value");
            Require.NotNull(type, "type");

            Value = value;
            Type = type;
            NumberStyles = numberStyles;
        }
开发者ID:parsnips,项目名称:Expressions,代码行数:9,代码来源:UnparsedNumber.cs


示例19: TryParsByte

        /// <summary>
        ///     Converts the string representation of a number in a specified numberStyle and culture-specific
        ///     format to its System.Byte equivalent. A return value indicates whether the
        ///     conversion succeeded or failed.
        /// </summary>
        /// <param name="value">
        ///     A string containing a number to convert. The string is interpreted using
        ///     the numberStyle specified by numberStyle.
        /// </param>
        /// <param name="numberStyle">
        ///     A bitwise combination of enumeration values that indicates the numberStyle elements
        ///     that can be present in s. A typical value to specify is System.Globalization.NumberStyles.Integer.
        /// </param>
        /// <param name="formatProvider">
        ///     An object that supplies culture-specific formatting information about s.
        ///     If formatProvider is null, the thread current culture is used.
        /// </param>
        /// <param name="outValue">
        ///     When this method returns, contains the 8-bit unsigned integer value equivalent
        ///     to the number contained in s if the conversion succeeded, or zero if the
        ///     conversion failed. The conversion fails if the s parameter is null or System.String.Empty,
        ///     is not of the correct format, or represents a number less than System.Byte.MinValue
        ///     or greater than System.Byte.MaxValue. This parameter is passed uninitialized.
        /// </param>
        /// <returns>Returns true if the parsing was successful, otherwise false.</returns>
        public static Boolean TryParsByte( this String value,
                                           NumberStyles numberStyle,
                                           IFormatProvider formatProvider,
                                           out Byte outValue )
        {
            value.ThrowIfNull( nameof( value ) );
            formatProvider.ThrowIfNull( nameof( formatProvider ) );

            return Byte.TryParse( value, numberStyle, formatProvider, out outValue );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:35,代码来源:String.TryParsByte.cs


示例20: TryParsDecimal

        /// <summary>
        ///     Converts the string representation of a number to its System.Decimal equivalent
        ///     using the specified numberStyle and culture-specific format. A return value indicates
        ///     whether the conversion succeeded or failed.
        /// </summary>
        /// <param name="value">The string representation of the number to convert.</param>
        /// <param name="numberStyle">
        ///     A bitwise combination of enumeration values that indicates the permitted
        ///     format of value. A typical value to specify is System.Globalization.NumberStyles.Number.
        /// </param>
        /// <param name="formatProvider">An object that supplies culture-specific parsing information about value.</param>
        /// <param name="outValue">
        ///     When this method returns, contains the System.Decimal number that is equivalent
        ///     to the numeric value contained in s, if the conversion succeeded, or is zero
        ///     if the conversion failed. The conversion fails if the s parameter is null
        ///     or System.String.Empty, is not in a format compliant with numberStyle, or represents
        ///     a number less than System.Decimal.MinValue or greater than System.Decimal.MaxValue.
        ///     This parameter is passed uninitialized.
        /// </param>
        /// <returns>Returns true if the parsing was successful, otherwise false.</returns>
        public static Boolean TryParsDecimal( this String value,
                                              NumberStyles numberStyle,
                                              IFormatProvider formatProvider,
                                              out Decimal outValue )
        {
            value.ThrowIfNull( nameof( value ) );
            formatProvider.ThrowIfNull( nameof( formatProvider ) );

            return Decimal.TryParse( value, NumberStyles.Any, CultureInfo.InvariantCulture, out outValue );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:30,代码来源:String.TryParsDecimal.cs



注:本文中的NumberStyles类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NumericUpDown类代码示例发布时间:2022-05-24
下一篇:
C# NumberLiteral类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap