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


C# Struct.ToString方法代码示例

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


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

示例1: Main

        public static void Main()
        {
            {
                TestLogger.Log("Testing cpobj...");
                var s = new Struct();
                TestLogger.Log(s.ToString());
                s.a = 3;
                s.b = true;
                s.c = 'x';
                s.d = 4;
                s.e = 2.5f;
                s.f = 9.4;
                s.g.x = 10;
                s.g.y = 12;
                s.h = "test";
                TestLogger.Log(s.ToString());
                var t = new Struct();
                TestLogger.Log(t.ToString());
                CopyStruct(ref s, ref t);
                TestLogger.Log(t.ToString());
            }

            {
                TestLogger.Log("Testing ldflda...");
                var s = new Struct();
                s.a = 3;
                s.g.x = 10;
                LogInt(ref s.a);
                LogInt(ref s.g.x);
            }

            {
                TestLogger.Log("Testing indexer...");
                Arr arr = new Arr();
                for (var i = 0; i < arr.Count; i++)
                    arr[i] = i * 37 % 11;
                for (var i = 0; i < arr.Count; i++)
                    TestLogger.Log(arr[i]);
            }

            {
                TestLogger.Log("Testing parameters...");
                var p = new Params(1, 2, 3, 4, 5);
                TestLogger.Log(p.ToString());
            }

        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:47,代码来源:Program.cs

示例2: StructSample

 public void StructSample()
 {
     var message = new Struct
     {
         Fields =
         {
             { "a", Value.ForNull() },
             { "b", Value.ForBool(false) },
             { "c", Value.ForNumber(10.5) },
             { "d", Value.ForString("text") },
             { "e", Value.ForList(Value.ForString("t1"), Value.ForNumber(5)) },
             { "f", Value.ForStruct(new Struct { Fields = { { "nested", Value.ForString("value") } } }) }
         }
     };
     AssertJson("{ 'a': null, 'b': false, 'c': 10.5, 'd': 'text', 'e': [ 't1', 5 ], 'f': { 'nested': 'value' } }", message.ToString());
 }
开发者ID:JeckyOH,项目名称:protobuf,代码行数:16,代码来源:JsonFormatterTest.cs

示例3: ToString_Struct

 public void ToString_Struct()
 {
     var message = new Struct { Fields = { { "foo", new Value { NumberValue = 20 } } } };
     var list = new RepeatedField<Struct> { message };
     var text = list.ToString();
     Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString());
 }
开发者ID:2php,项目名称:protobuf,代码行数:7,代码来源:RepeatedFieldTest.cs

示例4: StructSample

 public void StructSample()
 {
     var message = new Struct
     {
         Fields =
         {
             { "a", new Value { NullValue = new NullValue() } },
             { "b", new Value { BoolValue = false } },
             { "c", new Value { NumberValue = 10.5 } },
             { "d", new Value { StringValue = "text" } },
             { "e", new Value { ListValue = new ListValue { Values = { new Value { StringValue = "t1" }, new Value { NumberValue = 5 } } } } },
             { "f", new Value { StructValue = new Struct { Fields = { { "nested", new Value { StringValue = "value" } } } } } }
         }
     };
     AssertJson("{ 'a': null, 'b': false, 'c': 10.5, 'd': 'text', 'e': [ 't1', 5 ], 'f': { 'nested': 'value' } }", message.ToString());
 }
开发者ID:Holygitzdq,项目名称:ElVis,代码行数:16,代码来源:JsonFormatterTest.cs

示例5: ProcessDefinition

		protected override void ProcessDefinition(XmlNode node, BlamLib.CheApe.ProjectState state, BlamLib.IO.XmlStream s)
		{
			string name_str;

			switch (node.Name)
			{
				#region Tag Blocks
				case "blocks":
					s.SaveCursor(node);
					foreach (XmlNode n in s.Cursor.ChildNodes)
					{
						if (n.Name != "TagBlock") continue;

						s.SaveCursor(n);
						TagBlock block = new TagBlock(state, s);
						s.RestoreCursor();
						name_str = block.ToString();

						try { Blocks.Add(name_str, block); }
						catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag block definition", name_str); }
					}
					s.RestoreCursor();
					break;
				#endregion

				#region Tag Structs
				case "structs":
					s.SaveCursor(node);
					foreach (XmlNode n in s.Cursor.ChildNodes)
					{
						if (n.Name != "Struct") continue;

						s.SaveCursor(n);
						Struct str = new Struct(state, s);
						s.RestoreCursor();
						name_str = str.ToString();

						try { Structs.Add(name_str, str); }
						catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag struct definition", name_str); }
					}
					s.RestoreCursor();
					break;
				#endregion

				#region Tag Groups
				case "groups":
					s.SaveCursor(node);
					foreach (XmlNode n in s.Cursor.ChildNodes)
					{
						if (n.Name != "TagGroup") continue;

						s.SaveCursor(n);
						TagGroup group = new TagGroup(state, s);
						s.RestoreCursor();
						name_str = group.ToString();

						try { Groups.Add(name_str, group); }
						catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag group definition", name_str); }
					}
					s.RestoreCursor();
					break;
				#endregion
			}
		}
开发者ID:guardian2433,项目名称:open-sauce,代码行数:64,代码来源:Import.cs


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