本文整理汇总了C#中Variable.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.ToString方法的具体用法?C# Variable.ToString怎么用?C# Variable.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generalStringFormatTestToolStripMenuItem_Click
private void generalStringFormatTestToolStripMenuItem_Click(object sender, EventArgs e)
{
PrintLine("P E R F O R M I N G S T R I N G F O R M A T T E S T");
PrintLine("---------------------------------------------------------");
try
{
var U = new Variable();
var V = new Variable("V", "0");
var F1 = new Value(1.0 / 3.0);
var F2 = new Value(2.0 / 5.0);
PrintLine("DEFAULT:");
PrintLine("1/3 => " + F1.ToString(), Color.Blue);
PrintLine("2/5 => " + F2.ToString(), Color.Blue);
PrintLine("x => " + x.ToString(), Color.Blue);
PrintLine("U => " + U.ToString(), Color.Blue);
PrintLine("V_0 => " + V.ToString(), Color.Blue);
PrintLine("i => " + i.ToString(), Color.Blue);
PrintLine("C => " + C.ToString(), Color.Blue);
PrintLine("x + y => " + (x + y).ToString(), Color.Blue);
PrintLine("x - y => " + (x - y).ToString(), Color.Blue);
PrintLine("x * y => " + (x * y).ToString(), Color.Blue);
PrintLine("x / y => " + (x / y).ToString(), Color.Blue);
PrintLine("x ^ y => " + (x ^ y).ToString(), Color.Blue);
PrintLine("PARSE FRIENDLY:");
PrintLine("1/3 => " + F1.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("2/5 => " + F2.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("x => " + x.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("U => " + U.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("V_0 => " + V.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("i => " + i.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("C => " + C.ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("x + y => " + (x + y).ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("x - y => " + (x - y).ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("x * y => " + (x * y).ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("x / y => " + (x / y).ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("x ^ y => " + (x ^ y).ToString(ExpressionStringFormat.ParseFriendly), Color.Blue);
PrintLine("LATEX:");
PrintLine("1/3 => " + F1.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("2/5 => " + F2.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("x => " + x.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("U => " + U.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("V_0 => " + V.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("i => " + i.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("C => " + C.ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("x + y => " + (x + y).ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("x - y => " + (x - y).ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("x * y => " + (x * y).ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("x / y => " + (x / y).ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("x ^ y => " + (x ^ y).ToString(ExpressionStringFormat.LaTeX), Color.Blue);
PrintLine("SUCCESS", Color.Green);
}
catch (Exception ex)
{
PrintLine(ex.Message, Color.Red);
}
PrintLine();
}
示例2: TestToString
public void TestToString()
{
var v = new Variable(new uint[] {1, 3, 6});
Assert.AreEqual("Variable: Id: .1.3.6; Data: Null", v.ToString());
}
示例3: CreateName
private static string CreateName(Variable<GaussianDistribution> sumVariable,
IList<Variable<GaussianDistribution>> variablesToSum, double[] weights)
{
var sb = new StringBuilder();
sb.Append(sumVariable.ToString());
sb.Append(" = ");
for (int i = 0; i < variablesToSum.Count; i++)
{
bool isFirst = (i == 0);
if (isFirst && (weights[i] < 0))
{
sb.Append("-");
}
sb.Append(Math.Abs(weights[i]).ToString("0.00"));
sb.Append("*[");
sb.Append(variablesToSum[i]);
sb.Append("]");
bool isLast = (i == variablesToSum.Count - 1);
if (!isLast)
{
if (weights[i + 1] >= 0)
{
sb.Append(" + ");
}
else
{
sb.Append(" - ");
}
}
}
return sb.ToString();
}
示例4: VariableInfo
private VariableInfo(bool isRelObject, Variable name, string value)
{
this.name = string.Format("{0}{1}", isRelObject ? "Rel" : "", name.ToString());
this.value = value;
}