本文整理汇总了C#中Value.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Value.ToString方法的具体用法?C# Value.ToString怎么用?C# Value.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Value
的用法示例。
在下文中一共展示了Value.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Plural
public static string Plural(Value value)
{
if (value == Value.Six)
return "Sixes";
else
return value.ToString() + "s";
}
示例2: Eval
internal override Value Eval(Value arg, IScope scope)
{
if (arg.Type == ValueType.String)
return arg;
if (arg.Type == ValueType.Nil)
return new ValueString("");
return new ValueString(arg.ToString());
}
示例3: ToStringCore
private static LString ToStringCore( Value v, Thread l )
{
LString ret;
switch( v.ValueType )
{
case LValueType.Nil:
ret = Literals.Nil;
break;
case LValueType.Bool:
ret = v.IsTrue ? Literals.True : Literals.False;
break;
case LValueType.Number:
l.ConvertToString( ref v );
goto case LValueType.String;
case LValueType.String:
ret = (LString)v;
break;
default:
ret = new LString( v.ToString() );
break;
}
return ret;
}
示例4: 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();
}
示例5: ExcelConcat
public static Value ExcelConcat(Value v0, Value v1)
{
if (v0 is ErrorValue) return v0;
if (v1 is ErrorValue) return v1;
if ((v0 is TextValue || v0 is NumberValue) && (v1 is TextValue || v1 is NumberValue)) {
String s0 = v0.ToString(), s1 = v1.ToString();
// Avoid creating new String or TextValue objects when possible
if (s0 == "")
return v1 as TextValue ?? TextValue.Make(s1);
else if (s1 == "")
return v0 as TextValue ?? TextValue.Make(s0);
else
return TextValue.Make(s0 + s1);
} else
return ErrorValue.argTypeError;
}
示例6: Operate
public override Value Operate( Value First, Value Second )
{
if ( First is Reference ) First = ( First as Reference ).ReferencingValue;
if ( Second is Reference ) Second = ( Second as Reference ).ReferencingValue;
if ( First is Number && Second is Number )
{
return new Number( ( First as Number ).Val + ( Second as Number ).Val );
}
if ( First is String || Second is String )
{
return new String( First.ToString() + Second );
}
throw new Exception( "Both operands must be numbers or one of the operands must be a string" );
}
示例7: CompileTimeOperate
public Value CompileTimeOperate( Value First, Value Second )
{
if ( First == NoValue.Value || Second == NoValue.Value
|| First is Expression || Second is Expression
|| First is ExpressionSequence || Second is ExpressionSequence
|| First is CodeBlock || Second is CodeBlock )
{
return NoValue.Value;
}
if ( First is Number && Second is Number )
{
return new Number( ( First as Number ).Val + ( Second as Number ).Val );
}
if ( First is String || Second is String )
{
return new String( First.ToString() + Second );
}
return NoValue.Value;
}
示例8: basic
public void basic()
{
Value x = new Value(3);
Assert.That(x.IsInt());
Value y = new Value(4);
Assert.That(y.IsInt());
Value z = x * y;
Assert.That(z.IsInt());
Assert.That(z.ToString(), Is.EqualTo("12"));
object o = 8;
x = new Value(o);
Assert.That(x.IsInt());
z = x * y;
Assert.That(z.IsInt());
Assert.That(z.ToString(), Is.EqualTo("32"));
x = new Value("hello");
Assert.That(x.ToString(), Is.EqualTo("hello"));
Assert.That((new Value(1.5) * new Value(1.5)).ToString(), Is.EqualTo("2.25"));
}
示例9: assertType
public void assertType(string n, string s, Type t, Value v)
{
if (v.typ != t)
throw new EvalError(n + ": expected " + t.ToString() + ", " + s + " is " + v.typ.ToString() + " " + v.ToString());
}
示例10: AskForACard
public void AskForACard(List<Player> players, int myIndex, Deck stock, Value value)
{
//Ask the other players for a value. First add a line to the TextBox: "Joe asks
// if anyone has a Queen". Then go through the list of players that was passed in
//as a parameter and ask each player if he has any of the value (using his
// DoYouHaveAny() method). He'll pass you a deck of cards - add them to my deck.
// Keep track of how many cards were added. If there weren't any, you'll need
// to deal yourself a card from the stock (which was also passed as a parameter),
// add you'll have to add a line to the TextBox: "Joe had to draw from the stock"
int TotalCount = 0;
//int PlayerIndex = 0;
this.textBoxOnForm.Text += this.Name + " asks if anyone has a " + value.ToString() + "\r\n";
foreach (Player PlayerToAsk in players)
{
if (myIndex != players.IndexOf(PlayerToAsk))
{
Deck getCards = PlayerToAsk.DoYouHaveAny(value);
if (getCards.Count > 0)
{
TotalCount += getCards.Count;
for (int i = getCards.Count; i > 0; i--)
cards.Add(getCards.Deal(i - 1));
}
}
}
if (TotalCount == 0)
{
if(stock.Count > 0)
cards.Add(stock.Deal());
this.textBoxOnForm.Text += this.Name + " had to draw from the stock" + "\r\n";
}
}
示例11: print
private void print(Value value)
{
GlobalMemory.Instance.debugAddLine(value.ToString());
}