• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SimpleStruct类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SimpleStruct的典型用法代码示例。如果您正苦于以下问题:C# SimpleStruct类的具体用法?C# SimpleStruct怎么用?C# SimpleStruct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SimpleStruct类属于命名空间,在下文中一共展示了SimpleStruct类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_0_marshal_out_struct_delegate

	/* Test structures as out arguments of delegates */
	public static int test_0_marshal_out_struct_delegate () {
		SimpleStruct ss = new SimpleStruct ();
		OutStructDelegate d = new OutStructDelegate (delegate_test_struct_out);

		return mono_test_marshal_out_struct (1, out ss, 2, d);
	}
开发者ID:GirlD,项目名称:mono,代码行数:7,代码来源:pinvoke3.cs


示例17: test_0_marshal_byref_struct_delegate

	/* Test structures as byref arguments of delegates */
	public static int test_0_marshal_byref_struct_delegate () {
		SimpleStruct ss = new SimpleStruct ();
		TestDelegate d = new TestDelegate (delegate_test_struct_byref);
		
		ss.b = true;
		ss.d = "TEST1";

		if (mono_test_ref_vtype (1, ref ss, 2, d) != 0)
			return 1;

		if (! (ss.a && ss.b && ss.c && ss.d == "TEST3"))
			return 2;
		
		return 0;
	}
开发者ID:GirlD,项目名称:mono,代码行数:16,代码来源:pinvoke3.cs


示例18: mono_test_marshal_in_struct

	public static extern int mono_test_marshal_in_struct (int a, ref SimpleStruct ss, int b, InStructDelegate d);
开发者ID:GirlD,项目名称:mono,代码行数:1,代码来源:pinvoke3.cs


示例19: mono_test_marshal_out_struct

	public static extern int mono_test_marshal_out_struct (int a, out SimpleStruct ss, int b, OutStructDelegate d);
开发者ID:GirlD,项目名称:mono,代码行数:1,代码来源:pinvoke3.cs


示例20: mono_test_ref_vtype

	public static extern int mono_test_ref_vtype (int a, ref SimpleStruct ss, int b, TestDelegate d);
开发者ID:GirlD,项目名称:mono,代码行数:1,代码来源:pinvoke3.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SimpleType类代码示例发布时间:2022-05-24
下一篇:
C# SimpleStatement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap