当前位置: 首页>>代码示例>>C#>>正文


C# Globalization.NumberFormatInfo类代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {

            // установка разделитя в дробных суммах (зависит от настройки локализации)
            NumberFormatInfo formatSepar = new NumberFormatInfo();
            formatSepar.NumberDecimalSeparator = ".";


            // Загрузка документа в память
            XDocument xmlDoc = XDocument.Load("books.xml");


            IEnumerable<XElement> books = xmlDoc.Root.Elements("book")
                                           .Where(t => t.Element("genre").Value == "Computer");

            // XDocument.Descendants(XName)
            // Возвращает коллекцию подчиненных узлов для данного элемента.
            // Только элементы, имеющие соответствующее XName, включаются в коллекцию. 
            
            //IEnumerable<XElement> books = xmlDoc.Root.Descendants("book")
            //                              .Where(t => t.Element("genre").Value == "Computer");
           
            books.Remove();

            xmlDoc.Save("booksNew.xml");

            Console.WriteLine("Удаление выполнено успешно...");


            Console.ReadKey();
        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:31,代码来源:Program.cs

示例2: StringBuilderExtensions

 static StringBuilderExtensions()
 {
     if (m_numberFormatInfoHelper == null)
     {
         m_numberFormatInfoHelper = CultureInfo.InvariantCulture.NumberFormat.Clone() as NumberFormatInfo;
     }
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:StringBuilderExtensions.cs

示例3: NumberConversionRule

		/// <param name="typeCode">The <see cref="TypeCode"/> that this <see cref="NumberConversionRule"/> attempts to convert to.</param>
		public NumberConversionRule(TypeCode typeCode)
			: base(TypePointers.StringType)
		{
			if ((typeCode == TypeCode.String) || (typeCode == TypeCode.DateTime))
			{
				throw new ArgumentException("datatype cannot be String or DateTime.", "typeCode");
			}
			TypeCode = typeCode;
			numberFormatInfo = NumberFormatInfo.CurrentInfo;
			switch (typeCode)
			{
				case TypeCode.Decimal:
					NumberStyles = NumberStyles.Number;
					break;
				case TypeCode.Double:
				case TypeCode.Single:
					NumberStyles = NumberStyles.Float | NumberStyles.AllowThousands;
					break;
				case TypeCode.Byte:
				case TypeCode.SByte:
				case TypeCode.Int16:
				case TypeCode.UInt16:
				case TypeCode.Int32:
				case TypeCode.UInt32:
				case TypeCode.Int64:
				case TypeCode.UInt64:
					NumberStyles = NumberStyles.Integer;
					break;
			}
		}
开发者ID:thekindofme,项目名称:.netcf-Validation-Framework,代码行数:31,代码来源:NumberConversionRule.cs

示例4: ProcessLine

	private void ProcessLine (string testLine, NumberFormatInfo nfi)
	{
		string number = "0";
		string format = "X";
		string expected = "XXX";
		int idxStart;
		int idxEnd;

		idxStart = testLine.IndexOf ('(');
		if (idxStart != -1){
			idxStart++;
			idxEnd = testLine.IndexOf (')');
			number = testLine.Substring (idxStart,
						     idxEnd - idxStart);
		}

		idxStart = testLine.IndexOf ('(', idxStart);
		if (idxStart != -1) {
			idxStart++;
			idxEnd = testLine.IndexOf (')', idxStart);
			format = testLine.Substring (idxStart,
						     idxEnd - idxStart);
		}

		idxStart = testLine.IndexOf ('(', idxStart);
		if (idxStart != -1) {
			idxStart++;
			idxEnd = testLine.LastIndexOf (')');
			expected = testLine.Substring (idxStart,
						       idxEnd - idxStart);
		}

		DoTest (number, format, expected, nfi);
	}
开发者ID:salloo,项目名称:mono,代码行数:34,代码来源:IntegerFormatterTest.cs

示例5: GetNumberFormat2

		private NumberFormatInfo GetNumberFormat2()
		{
			NumberFormatInfo format = new NumberFormatInfo();
			
			format.NaNSymbol = "Geen";
			format.PositiveSign = "+";
			format.NegativeSign = "-";
			format.PerMilleSymbol = "x";
			format.PositiveInfinitySymbol = "Oneindig";
			format.NegativeInfinitySymbol = "-Oneindig";
			
			format.NumberDecimalDigits = 2; 
			format.NumberDecimalSeparator = ".";
			format.NumberGroupSeparator = ",";
			format.NumberGroupSizes = new int[] {3};
			format.NumberNegativePattern = 1;
			
			format.CurrencyDecimalDigits = 1;
			format.CurrencyDecimalSeparator = ".";
			format.CurrencyGroupSeparator = ",";
			format.CurrencyGroupSizes = new int[] {3};
			format.CurrencyNegativePattern = 3;
			format.CurrencyPositivePattern = 1;
			format.CurrencySymbol = "$";
			
			format.PercentDecimalDigits = 2; 
			format.PercentDecimalSeparator = ".";
			format.PercentGroupSeparator = ",";
			format.PercentGroupSizes = new int[] {3};
			format.PercentNegativePattern = 1;
			format.PercentPositivePattern = 2;
			format.PercentSymbol = "##";
			
			return format;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:35,代码来源:DoubleFormatterTest.cs

示例6: SetUp

        public override void SetUp()
        {
            base.SetUp();
            Dir = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000)));

            Document doc = new Document();
            Field field = NewStringField("field", "", Field.Store.NO);
            doc.Add(field);

            NumberFormatInfo df = new NumberFormatInfo();
            df.NumberDecimalDigits = 0;

            //NumberFormat df = new DecimalFormat("000", new DecimalFormatSymbols(Locale.ROOT));
            for (int i = 0; i < 1000; i++)
            {
                field.StringValue = i.ToString(df);
                writer.AddDocument(doc);
            }

            Reader = writer.Reader;
            Searcher = NewSearcher(Reader);
            writer.Dispose();
            if (VERBOSE)
            {
                Console.WriteLine("TEST: setUp searcher=" + Searcher);
            }
        }
开发者ID:joyanta,项目名称:lucene.net,代码行数:28,代码来源:TestWildcardRandom.cs

示例7: FromString

	public static float FromObject
				(Object Value, NumberFormatInfo NumberFormat)
			{
			#if !ECMA_COMPAT
				if(Value != null)
				{
					IConvertible ic = (Value as IConvertible);
					if(ic != null)
					{
						if(ic.GetTypeCode() != TypeCode.String)
						{
							return ic.ToSingle(NumberFormat);
						}
						else
						{
							return FromString(ic.ToString(null), NumberFormat);
						}
					}
					else
					{
						throw new InvalidCastException
							(String.Format
								(S._("VB_InvalidCast"),
								 Value.GetType(), "System.Single"));
					}
				}
				else
				{
					return 0.0f;
				}
			#else
				return (float)(DoubleType.FromObject(Value, NumberFormat));
			#endif
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:34,代码来源:SingleType.cs

示例8: FindCurrency

		private static void FindCurrency(ref int pos, string s, NumberFormatInfo nfi, ref bool foundCurrency) {
			if ((pos + nfi.CurrencySymbol.Length) <= s.Length &&
				 s.Substring(pos, nfi.CurrencySymbol.Length) == nfi.CurrencySymbol) {
				foundCurrency = true;
				pos += nfi.CurrencySymbol.Length;
			}
		}
开发者ID:bradparks,项目名称:DotNetAnywhere,代码行数:7,代码来源:ParseHelper.cs

示例9: BlackBoxFunction

 public BlackBoxFunction()
 {
     provider = new NumberFormatInfo();
     provider.NumberDecimalSeparator = ".";
    /// provider.NumberGroupSeparator = ".";
     provider.NumberGroupSizes = new int[] { 2 };
 }
开发者ID:unn-85m3,项目名称:project,代码行数:7,代码来源:BlackBoxFunction.cs

示例10: WriteCalibrationGroup

        internal static int WriteCalibrationGroup(ADatabase db, int average, double firmware, string serial)
        {
            try
            {
                NumberFormatInfo formatInfo = new NumberFormatInfo();
                formatInfo.NumberDecimalSeparator = ".";

                string sql = "INSERT INTO CalibrationGroup (NumOfAverage, Datetime, SensorSerial, SensorFirmware) VALUES (" + average.ToString() + ",'" + DateTime.Now.ToString("dd.MM.yy HH:mm:ss.ff") + "', '" + serial + "', " + firmware.ToString(formatInfo) + ")";
                NpgsqlCommand command = new NpgsqlCommand(sql, db.Connection);
                command.ExecuteNonQuery();

                sql = "SELECT currval(pg_get_serial_sequence('CalibrationGroup', 'calibrationgroupid'));";
                command = new NpgsqlCommand(sql, db.Connection);
                NpgsqlDataReader myreader = command.ExecuteReader();
                if (myreader.Read())
                {
                    int result = Convert.ToInt32(myreader[0].ToString());
                    myreader.Close();
                    return result;
                }
                else
                {
                    myreader.Close();
                    return -1;
                }
            }
            catch (Exception ex)
            {
                FileWorker.WriteEventFile(DateTime.Now, "ACalibrationDatabaseWorker", "WriteCalibrationGroup", ex.Message);
                return -1;
            }
        }
开发者ID:EugeneGudima,项目名称:Reflecta,代码行数:32,代码来源:ACalibrationDatabaseWorker.cs

示例11: FrameRateCounter

 public FrameRateCounter(ScreenManager screenManager)
     : base(screenManager.Game)
 {
     _screenManager = screenManager;
     _format = new NumberFormatInfo();
     _format.NumberDecimalSeparator = ".";
 }
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:7,代码来源:FramerateCounterComponent.cs

示例12: FrameRateCounter

 /// <summary>
 /// Initialize a new instance of FrameRateCounter
 /// </summary>
 /// <param name="game">The game</param>
 public FrameRateCounter(Game game)
     : base(game)
 {
     format = new NumberFormatInfo();
     format.NumberDecimalSeparator = ".";
     position = new Vector2(5, 5);
 }
开发者ID:vpuydoyeux,项目名称:Schmup,代码行数:11,代码来源:FrameRateCounter.cs

示例13: ToFloat

        public static float ToFloat(string s)
        {
            NumberFormatInfo _NumberFormatInfo = new NumberFormatInfo();
            _NumberFormatInfo.NumberDecimalSeparator = ".";

            return float.Parse(s,_NumberFormatInfo);
        }
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:7,代码来源:Q3ShaderParser.cs

示例14: ToString

        public static string ToString(float f)
        {
            NumberFormatInfo _NumberFormatInfo = new NumberFormatInfo();
            _NumberFormatInfo.NumberDecimalSeparator = ".";

            return f.ToString(_NumberFormatInfo);
        }
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:7,代码来源:Q3ShaderParser.cs

示例15: TransformPrice

 /// <summary>
 /// 把价格精确至小数点两位
 /// </summary>
 /// <param name="dPrice">价格</param>
 /// <returns>返回值</returns>
 public static string TransformPrice(double dPrice)
 {
     double d = dPrice;
     var myNfi = new NumberFormatInfo { NumberNegativePattern = 2 };
     string s = d.ToString("N", myNfi);
     return s;
 }
开发者ID:wenwu704341771,项目名称:MyHelper,代码行数:12,代码来源:MyStringHelper.cs


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