本文整理汇总了C#中Length.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Length.ToString方法的具体用法?C# Length.ToString怎么用?C# Length.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Length
的用法示例。
在下文中一共展示了Length.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToStringProviderTest
public void ToStringProviderTest()
{
double value = 10F;
Length target = new Length(value);
IFormatProvider provider = null;
string expected = value.ToString();
string actual;
actual = target.ToString(provider);
Assert.AreEqual(expected, actual);
}
示例2: ToStringFormatTest
public void ToStringFormatTest()
{
double value = 10F;
Length target = new Length(value);
string format = string.Empty;
string expected = value.ToString();
string actual;
actual = target.ToString(format);
Assert.AreEqual(expected, actual);
}
示例3: Column
/**
* construct a new TableColumn object
*/
public Column(IFormattingContext ctx, Length columnWidth,
float evaluatedWidth, bool spacing)
{
Spacing = spacing;
if(spacing)
{
if(columnWidth.Type == LengthType.Percentage)
{
MinimumWidth = 0;
}
else if(columnWidth.Fixed)
{
MinimumWidth = ctx.Evaluate(columnWidth);
}
else
{
// this is bad
throw new Exception("space columns must be either fixed or scaled widths");
}
}
else
{
MinimumWidth = evaluatedWidth;
}
if(columnWidth.Type == LengthType.Auto)
{
Type = ColumnType.Auto;
ScaleWidth = 0;
FixedWidth = 0;
Width = MinimumWidth;
}
else if(columnWidth.Type == LengthType.Fit)
{
Type = ColumnType.Fit;
ScaleWidth = 0;
FixedWidth = 0;
Width = MinimumWidth;
}
else if(columnWidth.Type == LengthType.Percentage)
{
Type = ColumnType.Scale;
ScaleWidth = columnWidth.Value / 100.0f;
FixedWidth = 0;
Width = MinimumWidth;
}
else if(columnWidth.Fixed)
{
Type = ColumnType.Fixed;
ScaleWidth = 0;
FixedWidth = MinimumWidth;
Width = MinimumWidth;
}
else
{
// this is bad
throw new Exception(columnWidth.ToString() + " is not a valid length type for a table");
}
}