本文整理汇总了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());
}
}
示例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());
}
示例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());
}
示例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());
}
示例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
}
}