当前位置: 首页>>代码示例>>C#>>正文


C# Value.ToString方法代码示例

本文整理汇总了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";
 }
开发者ID:bobbyquennell,项目名称:csharpstudy,代码行数:7,代码来源:Player.cs

示例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());
 }
开发者ID:loki3,项目名称:loki-pl1,代码行数:8,代码来源:String.cs

示例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;
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:29,代码来源:BaseLib.cs

示例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();
        }
开发者ID:HarrisonTotty,项目名称:Simplex.Math,代码行数:58,代码来源:MainForm.cs

示例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;
 }
开发者ID:Dugin13,项目名称:P10,代码行数:16,代码来源:Functions.cs

示例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" );
        }
开发者ID:LukaHorvat,项目名称:Kento,代码行数:15,代码来源:Operators.cs

示例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;
 }
开发者ID:LukaHorvat,项目名称:Kento,代码行数:19,代码来源:Operators.cs

示例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"));
        }
开发者ID:apmckinlay,项目名称:nsuneido,代码行数:22,代码来源:Value.cs

示例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());
 }
开发者ID:kjoenth,项目名称:kpu_mod,代码行数:5,代码来源:Processor.cs

示例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";
            }
        }
开发者ID:bobbyquennell,项目名称:csharpstudy,代码行数:34,代码来源:Player.cs

示例11: print

 private void print(Value value)
 {
     GlobalMemory.Instance.debugAddLine(value.ToString());
 }
开发者ID:brianex,项目名称:osu-sgl,代码行数:4,代码来源:PrintFunction.cs


注:本文中的Value.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。