本文整理汇总了C#中System.Globalization.NumberFormatInfo类的典型用法代码示例。如果您正苦于以下问题:C# NumberFormatInfo类的具体用法?C# NumberFormatInfo怎么用?C# NumberFormatInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NumberFormatInfo类属于System.Globalization命名空间,在下文中一共展示了NumberFormatInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TextNumberFormat
// CONSTRUCTORS
public TextNumberFormat() {
this.numberFormat = new System.Globalization.NumberFormatInfo();
this.numberFormatType = (int)TextNumberFormat.formatTypes.General;
this.groupingActivated = true;
this.separator = this.GetSeparator( (int)TextNumberFormat.formatTypes.General );
this.digits = 3;
}
开发者ID:DF-thangld,项目名称:web_game,代码行数:8,代码来源:AppSupportClass.cs
示例17: DecimalFormat
internal DecimalFormat(NumberFormatInfo info, char digit, char zeroDigit, char patternSeparator)
{
this.info = info;
this.digit = digit;
this.zeroDigit = zeroDigit;
this.patternSeparator = patternSeparator;
}
开发者ID:geoffkizer,项目名称:corefx,代码行数:7,代码来源:DecimalFormatter.cs
示例18: TestSetValue
public void TestSetValue()
{
string testStr = "testStr";
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.CurrencyDecimalSeparator = testStr;
Assert.Equal(testStr, nfi.CurrencyDecimalSeparator);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:NumberFormatInfoCurrencyDecimalSeparator.cs
示例19: TicksGenerator
static TicksGenerator()
{
//2013-11-12 13:00
var data = new string[] { "USDCHF;4;0.9197", "GBPUSD;4;1.5880", "EURUSD;4;1.3403", "USDJPY;2;99.73", "EURCHF;4;1.2324", "AUDBGN;4;1.3596", "AUDCHF;4;0.8567", "AUDJPY;2;92.96",
"BGNJPY;2;68.31", "BGNUSD;4;0.6848", "CADBGN;4;1.3901", "CADCHF;4;0.8759", "CADUSD;4;0.9527", "CHFBGN;4;1.5862", "CHFJPY;2;108.44", "CHFUSD;4;1.0875", "EURAUD;4;1.4375", "EURCAD;4;1.4064",
"EURGBP;4;0.8438", "EURJPY;4;133.66", "GBPAUD;4;1.7031", "GBPBGN;4;2.3169", "GBPCAD;4;1.6661", "GBPCHF;4;1.4603", "GBPJPY;2;158.37", "NZDUSD;4;0.8217", "USDBGN;4;1.4594", "USDCAD;4;1.0493",
"XAUUSD;2;1281.15", "XAGUSD;2;21.21", "$DAX;2;9078.20","$FTSE;2;6707.49","$NASDAQ;2;3361.02","$SP500;2;1771.32"};
symbols = new string[data.Length];
digits = new int[data.Length];
pipsizes = new double[data.Length];
prices = new double[data.Length];
providers = new string[] { "eSignal", "Gain", "NYSE", "TSE", "NASDAQ", "Euronext", "LSE", "SSE", "ASE", "SE", "NSEI" };
var format = new NumberFormatInfo();
format.NumberDecimalSeparator = ".";
for (int i = 0; i < data.Length; i++)
{
var tokens = data[i].Split(';'); //symbol;digits;price
symbols[i] = tokens[0];
digits[i] = Int32.Parse(tokens[1]);
pipsizes[i] = Math.Round(Math.Pow(10, -digits[i]), digits[i]);
prices[i] = Math.Round(Double.Parse(tokens[2], format), digits[i]);
}
}
开发者ID:KSLcom,项目名称:STSdb4,代码行数:28,代码来源:TicksGenerator.cs
示例20: ParseFloatStr
public static float ParseFloatStr(string str)
{
float single1;
if ((str == null) || (str == string.Empty))
{
return 0f;
}
str = str.Trim();
NumberFormatInfo info1 = new NumberFormatInfo();
info1.NumberDecimalSeparator = ".";
try
{
bool flag1 = false;
if (str.EndsWith("%"))
{
str = str.Substring(0, str.Length - 1);
flag1 = true;
}
single1 = float.Parse(str, NumberStyles.Any, info1);
if (flag1)
{
single1 /= 100f;
}
}
catch (Exception)
{
throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidnumberformat") + str);
}
return single1;
}
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:30,代码来源:Number.cs
注:本文中的System.Globalization.NumberFormatInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论