本文整理汇总了C#中CultureInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToString方法的具体用法?C# CultureInfo.ToString怎么用?C# CultureInfo.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest2
public bool PosTest2()
{
bool retVal = true;
const string c_TEST_DESC = "PosTest2: Verify the fr-FR CultureInfo's TextInfo";
const string c_TEST_ID = "P002";
TextInfo textInfoFrance = new CultureInfo("fr-FR").TextInfo;
String textinfoStr = "TextInfo - fr-FR";
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
if (textinfoStr != textInfoFrance.ToString())
{
string errorDesc = "Value is not " + textinfoStr + " as expected: Actual(" + textInfoFrance.ToString() + ")";
TestLibrary.TestFramework.LogError("003" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004" + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例2: Main
public static int Main()
{
try
{
CultureInfo ci = new CultureInfo("hu");
if (ci.ToString() != "hu")
{
Console.WriteLine("!!!ERROR-001: Result not as expected; expected value: hu, actual value: " + ci.ToString());
Console.WriteLine("FAIL");
return 99;
}
Console.WriteLine("Pass");
return 100;
}
catch (Exception e)
{
Console.WriteLine("!!!ERROR-XXX: Unexpected exception : " + e);
Console.WriteLine("FAIL");
return 101;
}
}
示例3: PosTest2
// Returns true if the expected result is right
// Returns false if the expected result is wrong
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest2: CultureTypes.NeutralCultures");
try
{
string expectName = "en";
CultureInfo myCultureInfo = new CultureInfo(expectName);
if (expectName != myCultureInfo.ToString())
{
TestLibrary.TestFramework.LogError("003", "ToString method should return " + expectName);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例4: PosTest3
// Returns true if the expected result is right
// Returns false if the expected result is wrong
public bool PosTest3()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest3: invariant culture ");
try
{
string expectName = "";
CultureInfo myCultureInfo = new CultureInfo(expectName);
if (expectName != myCultureInfo.ToString())
{
TestLibrary.TestFramework.LogError("005", "ToString method should return " + expectName);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例5: GoDoPictureFormatting
private void GoDoPictureFormatting(CultureInfo culture, ResourceWriter resWriter)
{
NumberFormatInfo numInfo = NumberFormatInfo.GetInstance(culture);
String[] bogusHeaders = new String[pictureFormats.Length];
for(int i=0; i<bogusHeaders.Length; i++){
bogusHeaders[i] = "AA_" + i;
}
GenerateXmlSchema(bogusHeaders, strPic);
StreamWriter xmlwriter = File.CreateText(xmlDataFile + "_" + strPic + "_" + culture.ToString() + ".xml");
XmlTextWriter myXmlTextWriter = new XmlTextWriter(xmlwriter);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartElement("NewDataSet");
WriteRealHeaders(myXmlTextWriter, bogusHeaders, pictureFormats);
{
Int64 value;
for(int i=0; i<numberTable.Length; i++){
value = numberTable[i];
myXmlTextWriter.WriteStartElement("Table");
myXmlTextWriter.WriteElementString("Number", value.ToString(numInfo));
for(int j=0; j<bogusHeaders.Length; j++){
myXmlTextWriter.WriteElementString(bogusHeaders[j], value.ToString(pictureFormats[j], numInfo));
}
myXmlTextWriter.WriteEndElement();
}
}
{
Decimal value;
for(int i=0; i<decimalTable.Length; i++){
value = decimalTable[i];
myXmlTextWriter.WriteStartElement("Table");
myXmlTextWriter.WriteElementString("Number", value.ToString(numInfo));
for(int j=0; j<bogusHeaders.Length; j++){
myXmlTextWriter.WriteElementString(bogusHeaders[j], value.ToString(pictureFormats[j], numInfo));
}
myXmlTextWriter.WriteEndElement();
}
}
{
Double value;
for(int i=0; i<doubleTable.Length; i++){
value = doubleTable[i];
myXmlTextWriter.WriteStartElement("Table");
myXmlTextWriter.WriteElementString("Number", value.ToString("R", numInfo));
for(int j=0; j<bogusHeaders.Length; j++){
myXmlTextWriter.WriteElementString(bogusHeaders[j], value.ToString(pictureFormats[j], numInfo));
}
myXmlTextWriter.WriteEndElement();
}
}
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
WriteDataToResourceFile(strPic, resWriter, culture);
}
示例6: WriteDataToResourceFile
private void WriteDataToResourceFile(String fileFormat, ResourceWriter resWriter, CultureInfo culture){
ArrayList xmlTable;
ArrayList xmlList;
Int32 ielementCount;
String elementName;
StringBuilder resourceHolder;
String resourceName;
XmlTextReader reader;
xmlTable = new ArrayList();
xmlList = new ArrayList();
reader = new XmlTextReader(xmlSchemaFile + "_" + fileFormat + ".xml");
ielementCount=0;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.HasAttributes)
{
if(++ielementCount>2){
xmlTable.Add(String.Empty);
xmlList.Add(reader[0]);
}
}
break;
}
}
reader.Close();
reader = new XmlTextReader(xmlDataFile + "_" + fileFormat + "_" + culture.ToString() + ".xml");
elementName = String.Empty;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
elementName = reader.Name;
break;
case XmlNodeType.Text:
if(xmlList.Contains(elementName)){
xmlTable[xmlList.IndexOf(elementName)] = (String)xmlTable[xmlList.IndexOf(elementName)] + reader.Value + separator;
}
break;
}
}
reader.Close();
resourceHolder = new StringBuilder();
foreach(String str111 in xmlList){
resourceHolder.Append((String)xmlTable[xmlList.IndexOf(str111)] + EOL);
}
resourceName = baseFileName + fileFormat + culture.ToString();
resWriter.AddResource(resourceName, resourceHolder.ToString());
}
示例7: GenerateXmlSchema
void GenerateXmlSchema(String[] formats, String fileFormatType, Boolean useCulture, CultureInfo culture)
{
StreamWriter writer;
if(useCulture)
writer = File.CreateText(xmlSchemaFile + "_" + fileFormatType + "_" + culture.ToString() + ".xml");
else
writer = File.CreateText(xmlSchemaFile + "_" + fileFormatType + ".xml");
XmlSchema schema;
XmlSchemaElement element;
XmlSchemaComplexType complexType;
XmlSchemaSequence sequence;
schema = new XmlSchema();
element = new XmlSchemaElement();
schema.Items.Add(element);
element.Name = "Table";
complexType = new XmlSchemaComplexType();
element.SchemaType = complexType;
sequence = new XmlSchemaSequence();
complexType.Particle = sequence;
element = new XmlSchemaElement();
element.Name = "DateTime";
element.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
sequence.Items.Add(element);
for(int i=0; i<formats.Length; i++)
{
element = new XmlSchemaElement();
element.Name = formats[i];
element.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
sequence.Items.Add(element);
}
schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
schema.Write(writer);
writer.Close();
}
示例8: Ctor_String
public void Ctor_String(string name, string[] expectedNames)
{
CultureInfo culture = new CultureInfo(name);
Assert.Contains(culture.Name, expectedNames);
Assert.Equal(name, culture.ToString(), ignoreCase: true);
}
示例9: GoDoPictureFormatting
private void GoDoPictureFormatting(CultureInfo culture)
{
Int64 numberValue;
Decimal decimalValue;
Double doubleValue;
String fileName = baseFileName + "_" + "Picture" + "_" + culture.ToString() + ".txt";
FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write);
StreamWriter writer = new StreamWriter(stream);
String s_pic_1 = "##00";
String s_pic_2 = "#,0#";
String s_pic_3 = "%#,0#";
String s_pic_4 = "%#,0#,,,";
String s_pic_5 = "#.0#";
String s_pic_6 = "#,.0#";
String s_pic_7 = "#..0.#";
String s_pic_8 = "00.00E+0";
String s_pic_9 = "00.00e-0";
String s_pic_10 = "00.00e0";
String s_pic_11 = "0.0e+0;-00;%0";
StringBuilder numbers = new StringBuilder("Number" + separator);
StringBuilder pic_1 = new StringBuilder(s_pic_1 + separator);
StringBuilder pic_2 = new StringBuilder(s_pic_2 + separator);
StringBuilder pic_3 = new StringBuilder(s_pic_3 + separator);
StringBuilder pic_4 = new StringBuilder(s_pic_4 + separator);
StringBuilder pic_5 = new StringBuilder(s_pic_5 + separator);
StringBuilder pic_6 = new StringBuilder(s_pic_6 + separator);
StringBuilder pic_7 = new StringBuilder(s_pic_7 + separator);
StringBuilder pic_8 = new StringBuilder(s_pic_8 + separator);
StringBuilder pic_9 = new StringBuilder(s_pic_9 + separator);
StringBuilder pic_10 = new StringBuilder(s_pic_10 + separator);
StringBuilder pic_11 = new StringBuilder(s_pic_11 + separator);
for(int i=0; i<numberTable.Length; i++){
numberValue = numberTable[i];
numbers.Append(numberValue.ToString() + separator);
pic_1.Append(numberValue.ToString(s_pic_1, NumberFormatInfo.GetInstance(culture)) + separator);
pic_2.Append(numberValue.ToString(s_pic_2, NumberFormatInfo.GetInstance(culture)) + separator);
pic_3.Append(numberValue.ToString(s_pic_3, NumberFormatInfo.GetInstance(culture)) + separator);
pic_4.Append(numberValue.ToString(s_pic_4, NumberFormatInfo.GetInstance(culture)) + separator);
pic_5.Append(numberValue.ToString(s_pic_5, NumberFormatInfo.GetInstance(culture)) + separator);
pic_6.Append(numberValue.ToString(s_pic_6, NumberFormatInfo.GetInstance(culture)) + separator);
pic_7.Append(numberValue.ToString(s_pic_7, NumberFormatInfo.GetInstance(culture)) + separator);
pic_8.Append(numberValue.ToString(s_pic_8, NumberFormatInfo.GetInstance(culture)) + separator);
pic_9.Append(numberValue.ToString(s_pic_9, NumberFormatInfo.GetInstance(culture)) + separator);
pic_10.Append(numberValue.ToString(s_pic_10, NumberFormatInfo.GetInstance(culture)) + separator);
pic_11.Append(numberValue.ToString(s_pic_11, NumberFormatInfo.GetInstance(culture)) + separator);
}
for(int i=0; i<decimalTable.Length; i++){
decimalValue = decimalTable[i];
numbers.Append(decimalValue.ToString() + separator);
pic_1.Append(decimalValue.ToString(s_pic_1, NumberFormatInfo.GetInstance(culture)) + separator);
pic_2.Append(decimalValue.ToString(s_pic_2, NumberFormatInfo.GetInstance(culture)) + separator);
pic_3.Append(decimalValue.ToString(s_pic_3, NumberFormatInfo.GetInstance(culture)) + separator);
pic_4.Append(decimalValue.ToString(s_pic_4, NumberFormatInfo.GetInstance(culture)) + separator);
pic_5.Append(decimalValue.ToString(s_pic_5, NumberFormatInfo.GetInstance(culture)) + separator);
pic_6.Append(decimalValue.ToString(s_pic_6, NumberFormatInfo.GetInstance(culture)) + separator);
pic_7.Append(decimalValue.ToString(s_pic_7, NumberFormatInfo.GetInstance(culture)) + separator);
pic_8.Append(decimalValue.ToString(s_pic_8, NumberFormatInfo.GetInstance(culture)) + separator);
pic_9.Append(decimalValue.ToString(s_pic_9, NumberFormatInfo.GetInstance(culture)) + separator);
pic_10.Append(decimalValue.ToString(s_pic_10, NumberFormatInfo.GetInstance(culture)) + separator);
pic_11.Append(decimalValue.ToString(s_pic_11, NumberFormatInfo.GetInstance(culture)) + separator);
}
for(int i=0; i<doubleTable.Length; i++){
if(i==0 || i==7)
continue;
doubleValue = doubleTable[i];
numbers.Append(doubleValue.ToString() + separator);
pic_1.Append(doubleValue.ToString(s_pic_1, NumberFormatInfo.GetInstance(culture)) + separator);
pic_2.Append(doubleValue.ToString(s_pic_2, NumberFormatInfo.GetInstance(culture)) + separator);
pic_3.Append(doubleValue.ToString(s_pic_3, NumberFormatInfo.GetInstance(culture)) + separator);
pic_4.Append(doubleValue.ToString(s_pic_4, NumberFormatInfo.GetInstance(culture)) + separator);
pic_5.Append(doubleValue.ToString(s_pic_5, NumberFormatInfo.GetInstance(culture)) + separator);
pic_6.Append(doubleValue.ToString(s_pic_6, NumberFormatInfo.GetInstance(culture)) + separator);
pic_7.Append(doubleValue.ToString(s_pic_7, NumberFormatInfo.GetInstance(culture)) + separator);
pic_8.Append(doubleValue.ToString(s_pic_8, NumberFormatInfo.GetInstance(culture)) + separator);
pic_9.Append(doubleValue.ToString(s_pic_9, NumberFormatInfo.GetInstance(culture)) + separator);
pic_10.Append(doubleValue.ToString(s_pic_10, NumberFormatInfo.GetInstance(culture)) + separator);
pic_11.Append(doubleValue.ToString(s_pic_11, NumberFormatInfo.GetInstance(culture)) + separator);
}
numbers.Append(EOL);
pic_1.Append(EOL);
pic_2.Append(EOL);
pic_3.Append(EOL);
pic_4.Append(EOL);
pic_5.Append(EOL);
pic_6.Append(EOL);
pic_7.Append(EOL);
pic_8.Append(EOL);
pic_9.Append(EOL);
pic_10.Append(EOL);
pic_11.Append(EOL);
writer.Write(numbers.ToString());
writer.Write(pic_1.ToString());
writer.Write(pic_2.ToString());
writer.Write(pic_3.ToString());
writer.Write(pic_4.ToString());
writer.Write(pic_5.ToString());
writer.Write(pic_6.ToString());
writer.Write(pic_7.ToString());
writer.Write(pic_8.ToString());
writer.Write(pic_9.ToString());
//.........这里部分代码省略.........