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


C# SimpleStruct类代码示例

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

示例2: Start

 // Use this for initialization
 void Start()
 {
     feeding_rate = power / defence;
     SimpleStruct ss = new SimpleStruct();
     ss.X = 500;
     ss.DisplayX();
 }
开发者ID:6samurai,项目名称:Staterra_github,代码行数:8,代码来源:Animal_properties.cs

示例3: testCall1

		public void testCall1() 
		{
			var x = new SimpleStruct();
			var a = ModifyA(x);
			AssertEquals("x.a", 0, x.a);
			AssertEquals("a", 27, a);
		}
开发者ID:Xtremrules,项目名称:dot42,代码行数:7,代码来源:TestStructSemantics.cs

示例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");
        }
        

    }
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:30,代码来源:StructInterfaceTest.cs

示例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;
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:8,代码来源:struct_opcodes.cs

示例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();
 }
开发者ID:JohnCDunn,项目名称:Course-Work-TTA,代码行数:9,代码来源:Struct.cs

示例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);
		}
开发者ID:Xtremrules,项目名称:dot42,代码行数:9,代码来源:TestStructSemantics.cs

示例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;
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:9,代码来源:Delegates.cs

示例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);
		}
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:TestStructSemantics.cs

示例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;
	}
开发者ID:GirlD,项目名称:mono,代码行数:10,代码来源:pinvoke3.cs

示例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;
	}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:55,代码来源:invoke.cs

示例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;
	}
开发者ID:GirlD,项目名称:mono,代码行数:12,代码来源:pinvoke3.cs

示例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;
	}
开发者ID:GirlD,项目名称:mono,代码行数:12,代码来源:pinvoke3.cs

示例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;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:13,代码来源:invoke.cs

示例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;
    }
开发者ID:robertmichaelwalsh,项目名称:CSharpFrontEnd,代码行数:38,代码来源:invoke.cs


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