本文整理汇总了C#中UInt32.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UInt32.ToString方法的具体用法?C# UInt32.ToString怎么用?C# UInt32.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UInt32
的用法示例。
在下文中一共展示了UInt32.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString_
public void ToString_()
{
UInt32 i = new UInt32();
foreach (var iteration in Benchmark.Iterations)
using (iteration.StartMeasurement())
{
i.ToString(); i.ToString(); i.ToString();
i.ToString(); i.ToString(); i.ToString();
i.ToString(); i.ToString(); i.ToString();
}
}
示例2: ToString_
public void ToString_()
{
UInt32 testint = new UInt32();
foreach (var iteration in Benchmark.Iterations)
using (iteration.StartMeasurement())
for (int i = 0; i < 10000; i++)
{
testint.ToString(); testint.ToString(); testint.ToString();
testint.ToString(); testint.ToString(); testint.ToString();
testint.ToString(); testint.ToString(); testint.ToString();
}
}
示例3: ToString
public static string ToString(UInt32 value)
{
return value.ToString();
}
示例4: ToString
public static string ToString(UInt32 value)
{
return value.ToString(null, NumberFormatInfo.InvariantInfo);
}
示例5: VerifyCtorUInt32
private static bool VerifyCtorUInt32(UInt32 value)
{
bool ret = true;
BigInteger bigInteger;
bigInteger = new BigInteger(value);
if (!bigInteger.Equals(value))
{
Console.WriteLine("Expected BigInteger {0} to be equal to UInt32 {1}", bigInteger, value);
ret = false;
}
if (String.CompareOrdinal(value.ToString(), bigInteger.ToString()) != 0)
{
Console.WriteLine("UInt32.ToString() and BigInteger.ToString() on {0} and {1} should be equal", value, bigInteger);
ret = false;
}
if (value != (UInt32)bigInteger)
{
Console.WriteLine("Expected BigInteger {0} to be equal to UInt32 {1}", bigInteger, value);
ret = false;
}
if (value != UInt32.MaxValue)
{
if ((UInt32)(value + 1) != (UInt32)(bigInteger + 1))
{
Console.WriteLine("Adding 1 to both {0} and {1} should remain equal", value, bigInteger);
ret = false;
}
}
if (value != UInt32.MinValue)
{
if ((UInt32)(value - 1) != (UInt32)(bigInteger - 1))
{
Console.WriteLine("Subtracting 1 from both {0} and {1} should remain equal", value, bigInteger);
ret = false;
}
}
Assert.True(VerifyBigintegerUsingIdentities(bigInteger, 0 == value), " Verification Failed");
return ret;
}
示例6: VerifyUInt32ImplicitCastToBigInteger
private static void VerifyUInt32ImplicitCastToBigInteger(UInt32 value)
{
BigInteger bigInteger = value;
Assert.Equal(value, bigInteger);
Assert.Equal(value.ToString(), bigInteger.ToString());
Assert.Equal(value, (UInt32)bigInteger);
if (value != UInt32.MaxValue)
{
Assert.Equal((UInt32)(value + 1), (UInt32)(bigInteger + 1));
}
if (value != UInt32.MinValue)
{
Assert.Equal((UInt32)(value - 1), (UInt32)(bigInteger - 1));
}
VerifyBigIntegerUsingIdentities(bigInteger, 0 == value);
}
示例7: NETUInt32ToString
/// <summary>
///Special column type UInt32 value converted to the specified format
/// </summary>
/// <param name="formatStyle">
/// Format parameters:
/// yyyy Represents the date year(4);yy Represents the date year(2);
/// mRepresents the date month(Automatic);mm Represents the date month(2);
/// dRepresents the date day(Automatic);ddRepresents the date day(2);
/// p1 represents first portion of the IP address;p2represents second portion of the IP address;p3 represents third portion of the IP address;represents fourth portion of the IP address;
/// v1represents the first part of the version number;v2 represents the second part of the version number;[The version number format:The major version number.Minor version number]
/// vs1represents the first part of the version number;vs2represents the second part of the version number;vs3represents the third part of the version number;vs4represents the fourth part of the version number;[The version number format:x.x.x.x]
/// </param>
/// <returns></returns>
public static string NETUInt32ToString(UInt32 intValue,string formatStyle)
{
//Convert hexadecimal values
string valueString = intValue.ToString("X");
string strReturn = formatStyle.ToUpper();
//Format
string strTemp = "00000000";
strTemp = strTemp.Remove(0, valueString.Length) + valueString;
string strPart1 = strTemp.Substring(0, 2);
string strPart2 = strTemp.Substring(2, 2);
string strPart3 = strTemp.Substring(4, 2);
string strPart4 = strTemp.Substring(6, 2);
//Years of the date of treatment
if (strReturn.IndexOf("YYYY") != -1)
{
strReturn = strReturn.Replace("YYYY", int.Parse(strPart1 + strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("YY") != -1)
{
strReturn = strReturn.Replace("YY", (int.Parse(strPart1 + strPart2, System.Globalization.NumberStyles.AllowHexSpecifier) % 100).ToString());
}
//Months of the date of treatment
if (strReturn.IndexOf("MM") != -1)
{
int mm = int.Parse(strPart3, System.Globalization.NumberStyles.AllowHexSpecifier);
strReturn = strReturn.Replace("MM", ((mm>10?mm.ToString():"0"+mm.ToString())));
}
if (strReturn.IndexOf("M") != -1)
{
strReturn = strReturn.Replace("M", int.Parse(strPart3, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//Days of the date of treatment
if (strReturn.IndexOf("DD") != -1)
{
int dd = int.Parse(strPart4, System.Globalization.NumberStyles.AllowHexSpecifier);
strReturn = strReturn.Replace("DD", ((dd > 10 ? dd.ToString() : "0" + dd.ToString())));
}
if (strReturn.IndexOf("D") != -1)
{
strReturn = strReturn.Replace("D", int.Parse(strPart4, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//Processing IP addresses
if (strReturn.IndexOf("P1") != -1)
{
strReturn = strReturn.Replace("P1", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("P2") != -1)
{
strReturn = strReturn.Replace("P2", int.Parse(strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("P3") != -1)
{
strReturn = strReturn.Replace("P3", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("P4") != -1)
{
strReturn = strReturn.Replace("P4", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//Processing version number[The major version number.Minor version number]
if (strReturn.IndexOf("V1") != -1)
{
strReturn = strReturn.Replace("V1", int.Parse(strPart1 + strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("V2") != -1)
{
strReturn = strReturn.Replace("V2", int.Parse(strPart3 + strPart4, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//Processing version number[X.X.X.X]
if (strReturn.IndexOf("VS1") != -1)
{
strReturn = strReturn.Replace("VS1", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("VS2") != -1)
{
strReturn = strReturn.Replace("VS2", int.Parse(strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("VS3") != -1)
{
strReturn = strReturn.Replace("VS3", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("VS4") != -1)
{
strReturn = strReturn.Replace("VS4", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
return strReturn;
}
示例8: VerifyCtorUInt32
private static void VerifyCtorUInt32(UInt32 value)
{
BigInteger bigInteger = new BigInteger(value);
Assert.Equal(value, bigInteger);
Assert.Equal(0, String.CompareOrdinal(value.ToString(), bigInteger.ToString()));
Assert.Equal(value, (UInt32)bigInteger);
if (value != UInt32.MaxValue)
{
Assert.Equal((UInt32)(value + 1), (UInt32)(bigInteger + 1));
}
if (value != UInt32.MinValue)
{
Assert.Equal((UInt32)(value - 1), (UInt32)(bigInteger - 1));
}
VerifyBigIntegerUsingIdentities(bigInteger, 0 == value);
}
示例9: AllPrimitivesMethod
private static string AllPrimitivesMethod(
bool boolean,
string str,
char character,
byte unsignedbyte,
sbyte signedbyte,
Int16 int16,
UInt16 uint16,
Int32 int32,
UInt32 uint32,
Int64 int64,
UInt64 uint64,
Single single,
Double dbl)
{
StringBuilder builder = new StringBuilder();
builder.Append(boolean.ToString() + ", ");
builder.Append(str + ", ");
builder.Append(character.ToString() + ", ");
builder.Append(unsignedbyte.ToString() + ", ");
builder.Append(signedbyte.ToString() + ", ");
builder.Append(int16.ToString() + ", ");
builder.Append(uint16.ToString() + ", ");
builder.Append(int32.ToString() + ", ");
builder.Append(uint32.ToString() + ", ");
builder.Append(int64.ToString() + ", ");
builder.Append(uint64.ToString() + ", ");
builder.Append(single.ToString() + ", ");
builder.Append(dbl);
return builder.ToString();
}
示例10: DHUInt32ToString
/// <summary>
/// 特列UInt32类型值转换成指定的格式
/// </summary>
/// <param name="formatStyle">
/// 格式参数:
/// yyyy表示日期的年(4位);yy表示日期的年(2位);
/// m表示日期的月(自动);mm表示日期的月(2位);
/// d表示日期的天(自动);dd表示日期的天(2位);
/// p1表示IP地址的第一部分;p2表示IP地址的第二部分;p3表示IP地址的第三部分;p4表示IP地址的第四部分;
/// v1表示版本号的第一部分;v2表示版本号的第2部分;[版本号格式:主版本号.次版本号]
/// vs1表示版本号的第一部分;vs2表示版本号的第2部分;vs3表示版本号的第3部分;vs4表示版本号的第4部分;[版本号格式:x.x.x.x]
/// </param>
/// <returns></returns>
public static string DHUInt32ToString(UInt32 intValue,string formatStyle)
{
//转换为16进制表示值
string valueString = intValue.ToString("X");
string strReturn = formatStyle.ToUpper();
//格式化
string strTemp = "00000000";
strTemp = strTemp.Remove(0, valueString.Length) + valueString;
string strPart1 = strTemp.Substring(0, 2);
string strPart2 = strTemp.Substring(2, 2);
string strPart3 = strTemp.Substring(4, 2);
string strPart4 = strTemp.Substring(6, 2);
//日期年的处理
if (strReturn.IndexOf("YYYY") != -1)
{
strReturn = strReturn.Replace("YYYY", int.Parse(strPart1 + strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("YY") != -1)
{
strReturn = strReturn.Replace("YY", (int.Parse(strPart1 + strPart2, System.Globalization.NumberStyles.AllowHexSpecifier) % 100).ToString());
}
//日期月的处理
if (strReturn.IndexOf("MM") != -1)
{
int mm = int.Parse(strPart3, System.Globalization.NumberStyles.AllowHexSpecifier);
strReturn = strReturn.Replace("MM", ((mm>10?mm.ToString():"0"+mm.ToString())));
}
if (strReturn.IndexOf("M") != -1)
{
strReturn = strReturn.Replace("M", int.Parse(strPart3, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//日期日的处理
if (strReturn.IndexOf("DD") != -1)
{
int dd = int.Parse(strPart4, System.Globalization.NumberStyles.AllowHexSpecifier);
strReturn = strReturn.Replace("DD", ((dd > 10 ? dd.ToString() : "0" + dd.ToString())));
}
if (strReturn.IndexOf("D") != -1)
{
strReturn = strReturn.Replace("D", int.Parse(strPart4, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//IP地址的处理
if (strReturn.IndexOf("P1") != -1)
{
strReturn = strReturn.Replace("P1", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("P2") != -1)
{
strReturn = strReturn.Replace("P2", int.Parse(strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("P3") != -1)
{
strReturn = strReturn.Replace("P3", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("P4") != -1)
{
strReturn = strReturn.Replace("P4", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//版本号的处理[主版本号.次版本号]
if (strReturn.IndexOf("V1") != -1)
{
strReturn = strReturn.Replace("V1", int.Parse(strPart1 + strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("V2") != -1)
{
strReturn = strReturn.Replace("V2", int.Parse(strPart3 + strPart4, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
//版本号的处理[X.X.X.X]
if (strReturn.IndexOf("VS1") != -1)
{
strReturn = strReturn.Replace("VS1", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("VS2") != -1)
{
strReturn = strReturn.Replace("VS2", int.Parse(strPart2, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("VS3") != -1)
{
strReturn = strReturn.Replace("VS3", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
if (strReturn.IndexOf("VS4") != -1)
{
strReturn = strReturn.Replace("VS4", int.Parse(strPart1, System.Globalization.NumberStyles.AllowHexSpecifier).ToString());
}
return strReturn;
}