本文整理汇总了C#中SimpleStruct类的典型用法代码示例。如果您正苦于以下问题:C# SimpleStruct类的具体用法?C# SimpleStruct怎么用?C# SimpleStruct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleStruct类属于命名空间,在下文中一共展示了SimpleStruct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test1
public static SimpleStruct Test1(SimpleStruct
ss)
{
Console.WriteLine
("Test1 called "
+
ss.a
+
" "
+
ss.b);
SimpleStruct
res
=
new
SimpleStruct
();
res.a
=
!ss.a;
res.b
=
!ss.b;
return
res;
}
示例2: Start
// Use this for initialization
void Start()
{
feeding_rate = power / defence;
SimpleStruct ss = new SimpleStruct();
ss.X = 500;
ss.DisplayX();
}
示例3: testCall1
public void testCall1()
{
var x = new SimpleStruct();
var a = ModifyA(x);
AssertEquals("x.a", 0, x.a);
AssertEquals("a", 27, a);
}
示例4: Main
public static void Main()
{
SimpleStruct ss = new SimpleStruct();
ss.X = 5;
ss.DisplayX();
SS si = (SS) ss;
si.X = 90;
si.DisplayX();
ss = (SimpleStruct) si ;
ss.X = 5;
ss.DisplayX();
SimpleClass ss1 = new SimpleClass();
ss1.X = 5;
ss1.DisplayX();
try {
ss1 = (SimpleClass) si ;
ss1.X = 5;
ss1.DisplayX();
}
catch(Exception)
{
Console.WriteLine("Failed to cast");
}
}
示例5: aMethod_Inline
public static SimpleStruct aMethod_Inline(SimpleStruct Struct)
{
Struct.i = 10;
Struct.str = "abc";
int x = Struct.i;
string str1 = Struct.str;
return Struct;
}
示例6: Main
public static void Main()
{
Console.WriteLine("instaniante a ss structure object");
SimpleStruct ss = new SimpleStruct();
Console.WriteLine("Set the integer to 5 in the ss structure object");
ss.X = 5;
Console.WriteLine("Call the Displayx function in the ss structure object");
ss.DisplayX();
}
示例7: testLocalVar1
public void testLocalVar1()
{
var x = new SimpleStruct();
x.a = 5;
var y = x;
y.a = 6;
AssertEquals("x.a", 5, x.a);
AssertEquals("y.a", 6, y.a);
}
示例8: InstanceDelegateWithStruct
public static bool InstanceDelegateWithStruct() {
Delegates delegates = new Delegates();
SimpleStruct simpleStruct = new SimpleStruct();
simpleStruct.i = 2;
simpleStruct.j = 3;
StructDel sd = new StructDel(delegates.StructAsArgument);
int result = sd(simpleStruct);
return result == 5 ? true : false;
}
示例9: testArray1
public void testArray1()
{
var x = new SimpleStruct[5];
var y = new SimpleStruct[5];
x[0].a = 5;
y[0] = x[0];
y[0].a = 6;
AssertEquals("x[0].a", 5, x[0].a);
AssertEquals("y[0].a", 6, y[0].a);
}
示例10: delegate_test_struct_out
public static int delegate_test_struct_out (int a, out SimpleStruct ss, int b)
{
ss.a = true;
ss.b = true;
ss.c = true;
ss.d = "TEST3";
ss.d2 = "TEST4";
return 0;
}
示例11: Main
static int Main () {
Type t = typeof (Test);
MethodInfo m2 = t.GetMethod ("Test2");
if (m2 != null)
return 1;
MethodInfo m1 = t.GetMethod ("Test1");
if (m1 == null)
return 1;
object [] args = new object [1];
SimpleStruct ss = new SimpleStruct ();
ss.a = true;
ss.b = false;
args [0] = ss;
SimpleStruct res = (SimpleStruct)m1.Invoke (null, args);
if (res.a == true)
return 1;
if (res.b == false)
return 1;
// Test that the objects for byref valuetype arguments are
// automatically created
MethodInfo m3 = typeof(Test).GetMethod("Foo");
args = new object[2];
m3.Invoke(null, args);
if ((((int)(args [0])) != 20) || (((int)(args [1])) != 30))
return 2;
// Test the return value from ConstructorInfo.Invoke when a precreated
// valuetype is used.
ConstructorInfo ci = typeof (SimpleStruct).GetConstructor (new Type [] { typeof (bool) });
ci.Invoke (ss, new object [] { false });
// Test invoking of the array Get/Set methods
string[,] arr = new string [10, 10];
arr.GetType ().GetMethod ("Set").Invoke (arr, new object [] { 1, 1, "FOO" });
string s = (string)arr.GetType ().GetMethod ("Get").Invoke (arr, new object [] { 1, 1 });
if (s != "FOO")
return 3;
// Test the sharing of runtime invoke wrappers for string ctors
typeof (string).GetConstructor (new Type [] { typeof (char[]) }).Invoke (null, new object [] { new char [] { 'a', 'b', 'c' } });
typeof (Assembly).GetMethod ("GetType", new Type [] { typeof (string), }).Invoke (typeof (int).Assembly, new object [] { "A" });
return 0;
}
示例12: delegate_test_struct
public static SimpleStruct delegate_test_struct (SimpleStruct ss)
{
SimpleStruct res;
res.a = !ss.a;
res.b = !ss.b;
res.c = !ss.c;
res.d = ss.d + "-RES";
res.d2 = ss.d2 + "-RES";
return res;
}
示例13: delegate_test_struct_byref
public static int delegate_test_struct_byref (int a, ref SimpleStruct ss, int b)
{
if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2") {
ss.a = true;
ss.b = true;
ss.c = true;
ss.d = "TEST3";
return 0;
}
return 1;
}
示例14: test_0_ctor_vtype
public static int test_0_ctor_vtype () {
// Test the return value from ConstructorInfo.Invoke when a precreated
// valuetype is used.
SimpleStruct ss = new SimpleStruct ();
ss.a = true;
ss.b = false;
ConstructorInfo ci = typeof (SimpleStruct).GetConstructor (new Type [] { typeof (bool) });
ci.Invoke (ss, new object [] { false });
return 0;
}
示例15: Main
static int Main()
{
Type t = typeof (Test);
MethodInfo m2 = t.GetMethod ("Test2");
if (m2 != null)
return 1;
MethodInfo m1 = t.GetMethod ("Test1");
if (m1 == null)
return 1;
object [] args = new object [1];
SimpleStruct ss = new SimpleStruct ();
ss.a = true;
ss.b = false;
args [0] = ss;
SimpleStruct res = (SimpleStruct)m1.Invoke (null, args);
if (res.a == true)
return 1;
if (res.b == false)
return 1;
// Test that the objects for byref valuetype arguments are
// automatically created
MethodInfo m3 = typeof(Test).GetMethod("Foo");
args = new object[2];
m3.Invoke(null, args);
if ((((int)(args [0])) != 20) || (((int)(args [1])) != 30))
return 2;
return 0;
}