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


C# KeyValuePair.ToString方法代码示例

本文整理汇总了C#中KeyValuePair.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# KeyValuePair.ToString方法的具体用法?C# KeyValuePair.ToString怎么用?C# KeyValuePair.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyValuePair的用法示例。


在下文中一共展示了KeyValuePair.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PosTest2

    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2: Create a new instance of KeyValuePair.key is string and value is int");
        try
        {
            string ExpectValue1 = "HELLO";
            int ExpectValue2 = 1;
            KeyValuePair<int, string> myKeValuePair = new KeyValuePair<int, string>(ExpectValue2, ExpectValue1);
            string expectValue = "[1, HELLO]";
            string actualValue = myKeValuePair.ToString();
            if (actualValue != expectValue)
            {
                TestLibrary.TestFramework.LogError("002.1", "calling tostring method  should return " + expectValue);
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:27,代码来源:keyvaluepairtostring.cs

示例2: TestUseCase

 public static void TestUseCase()
 {
     var pair = new KeyValuePair<int, string>(1, "value");
     Assert.AreEqual(pair.Key, 1, "Bridge479 Key");
     Assert.AreEqual(pair.Value, "value", "Bridge479 Value");
     Assert.AreEqual(pair.ToString(), "[1, value]", "Bridge479 ToString");
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:7,代码来源:N479.cs

示例3: TestUseCase

        public static void TestUseCase(Assert assert)
        {
            assert.Expect(3);

            var pair = new KeyValuePair<int, string>(1, "value");
            assert.Equal(pair.Key, 1, "Bridge479 Key");
            assert.Equal(pair.Value, "value", "Bridge479 Value");
            assert.Equal(pair.ToString(), "[1, value]", "Bridge479 ToString");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:9,代码来源:N479.cs

示例4: PosTest3

 // Returns true if the expected result is right
 // Returns false if the expected result is wrong
 public bool PosTest3()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest3: Create a new instance of KeyValuePair,key is 0 and value is null.");
     try
     {
         KeyValuePair<int, string> myKeValuePair = new KeyValuePair<int, string>();
         string expectValue = "[0, ]";
         string actualValue = myKeValuePair.ToString();
         if (expectValue != actualValue)
         {
             TestLibrary.TestFramework.LogError("003.1", "the key of KeyValuePair should return " + actualValue);
             retVal = false;
         }
        
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
         retVal = false;
     }
     return retVal;
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:25,代码来源:keyvaluepairtostring.cs

示例5: KVPToString

 public void KVPToString()
 {
     KeyValuePair<Char, String> input1 = new KeyValuePair<char, string>('A', "alpha");
     Assert.AreEqual("A -> alpha", input1.ToString(" -> ", true));
     Assert.AreEqual("alphaA", input1.ToString("", false));
 }
开发者ID:Klotos,项目名称:KlotosLib,代码行数:6,代码来源:CollectionsToolsTests.cs

示例6: getMove


//.........这里部分代码省略.........
                case CubeFace.F:
                case CubeFace.B:
                    switch(swipedFace.direction){
                        case SwipeDirection.H:
                            switch(swipedFace.layer){
                                case 0:
                                    m = Move.U;
                                    break;
                                case 1:
                                    m = Move.E;
                                    break;
                                case 2:
                                    m = Move.D;
                                    break;
                            }
                            break;
                        case SwipeDirection.V:
                            switch (swipedFace.layer) {
                                case 0:
                                    m = Move.L;
                                    break;
                                case 1:
                                    m = Move.M;
                                    break;
                                case 2:
                                    m = Move.R;
                                    break;
                            }
                            break;
                    }
                    break;
                case CubeFace.R:
                case CubeFace.L:
                    switch (swipedFace.direction) {
                        case SwipeDirection.H:
                            switch(swipedFace.layer){
                                case 0:
                                    m = Move.D;
                                    break;
                                case 1:
                                    m = Move.E;
                                    break;
                                case 2:
                                    m = Move.U;
                                    break;
                            }
                            break;
                        case SwipeDirection.V:
                            switch (swipedFace.layer) {
                                case 0:
                                    m = Move.B;
                                    break;
                                case 1:
                                    m = Move.S;
                                    break;
                                case 2:
                                    m = Move.F;
                                    break;
                            }
                            break;
                    }
                    break;
                case CubeFace.U:
                case CubeFace.D:
                    switch (swipedFace.direction) {
                        case SwipeDirection.H:
                            switch (swipedFace.layer) {
                                case 0:
                                    m = Move.B;
                                    break;
                                case 1:
                                    m = Move.S;
                                    break;
                                case 2:
                                    m = Move.F;
                                    break;
                            }
                            break;
                        case SwipeDirection.V:
                            switch (swipedFace.layer) {
                                case 0:
                                    m = Move.L;
                                    break;
                                case 1:
                                    m = Move.M;
                                    break;
                                case 2:
                                    m = Move.R;
                                    break;
                            }
                            break;
                    }
                    break;
            }

            retval = new KeyValuePair<Move,RotationDirection>(m, getRotationDirection(swipedFace));
            Debug.Print("Move: " + retval.ToString());

            return retval;
        }
开发者ID:paulbarbu,项目名称:magic-cube,代码行数:101,代码来源:Movement.cs


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