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

C# MyStruct类代码示例

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

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



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

示例1: Caller

    // Caller method takes 5 parameters.  4 in register and 1 on the stack.  The important details here are that
    //  * Must take a value type as a parameter
    //  * The value type must be of size 1, 2, 4 or 8
    //  * That parameter must be passed on the stack.  Typically this is the 5th parameter and beyond for
    //    static methods, or 4th and beyond for instance methods.
    static int Caller(int regParam1, int regParam2, int regParam3, int regParam4, MyStruct stackParam1)
    {
        // Add random calls to block inlining of this call into the parent frame.
        Console.Write("Let's ");
        Console.Write("Discourage ");
        Console.Write("Inlining ");
        Console.Write("Of ");
        Console.Write("Caller ");
        Console.Write("Into ");
        Console.WriteLine("Main.");

        // Avoid touching stackParam1 except to pass it off to the callee.  Any non-trivial usage of
        // stackParam1 or other code within this method will likely eliminate the potential for tail
        // call optimization.
        // if (stackParam1.C == 9) Console.WriteLine("C == 9");

        // Now make our call.
        // The keys here are:
        //  * That the incoming value type stack parameter must be passed to the callee in register.
        //  * Tail call optimizations must be enabled
        //  * The tail call optimization must fire (see above for an example of what might block it).
        // The JIT will incorrectly load the outgoing parameter from the incorrect stack location
        // on the local frame.
        return Callee(stackParam1, regParam1, regParam2, regParam3, regParam4);
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:30,代码来源:GitHub_1296.cs


示例2: Main

        static void Main(string[] args)
        {
            List<MyStruct> my_list = new List<MyStruct>();

            for (int currEntry = 0; currEntry < 100000; currEntry++)
            {
                MyStruct mys = new MyStruct();
                mys.my_s2.my_long = 999;

                mys.my_int = 33;
                mys.my_ary = new byte[] { 4, 5, 6, 7 };
                my_list.Add(mys);
            }
            MemoryStream ms = new MemoryStream();
            BinaryFormatter bf = new BinaryFormatter();

            DateTime startTime = DateTime.Now;
            bf.Serialize(ms, my_list);
            ms.Position = 0;

            List<MyStruct> my_list2 = (List<MyStruct>)bf.Deserialize(ms);
            DateTime endTime = DateTime.Now;

            TimeSpan ts = new TimeSpan(endTime.Ticks - startTime.Ticks);


            Console.WriteLine("Serialize/Deserialize span:" + ts.Milliseconds);

        }
开发者ID:ehershey,项目名称:development,代码行数:29,代码来源:Program.cs


示例3: Main

	static void Main()
	{
		var inst1 = new MyClass();
		inst1.x = 10;
		ChangeMyClass(inst1);
		System.Console.WriteLine(inst1.x);

		var inst2 = new MyStruct();
		inst2.x = 10;
		ChangeMyStruct(ref inst2);
		System.Console.WriteLine(inst2.x);

		var inst3 = inst1;
		inst1.x = 5;
		System.Console.WriteLine(inst3.x);

		var inst4 = inst2;
		inst2.x = 5;
		System.Console.WriteLine(inst4.x);

		var inst5 = new MyClass();
		inst5.x = 5;
		System.Console.WriteLine(System.String.Format("inst3 and inst1 are {0}equal!", (inst3 == inst1) ? "" : "not "));
		System.Console.WriteLine(System.String.Format("inst5 and inst1 are {0}equal!", (inst5 == inst1) ? "" : "not "));

		var s1 = "Hello Trainer!";
		System.String s2 = s1;
		s1 = "Hello Trainees!";
		System.Console.WriteLine(s1);
		System.Console.WriteLine(s2);
		System.Console.WriteLine(System.String.Format("s1 and s2 are {0}equal!", (s1==s2) ? "" : "not "));

		var s3 = System.Console.ReadLine();
		System.Console.WriteLine(System.String.Format("s1 and s3 are {0}equal!", (s1==s3) ? "" : "not "));
	}
开发者ID:mkandroid15,项目名称:Samples,代码行数:35,代码来源:ReferenceAndValue.cs


示例4: Main

 static void Main(string[] args)
 {
     Checker check = new Checker(); 
     ClassA try1 = new ClassA();
     ClassB try2 = new ClassB();
     ClassC try3 = new ClassC();
     ClassD try4 = new ClassD();
     MyStruct try5 = new MyStruct();
     object try6 = try5;
     Console.WriteLine("Analyzing ClassA type variable:");
                       // Анализ переменной типа ClassA 
     check.Check(try1);
     Console.WriteLine("\nAnalyzing ClassB type variable:"); 
                       // Анализ переменной типа ClassB 
     check.Check(try2);
     Console.WriteLine("\nAnalyzing ClassC type variable:");
                       // Анализ переменной типа ClassC 
     check.Check(try3);
     Console.WriteLine("\nAnalyzing ClassD type variable:");
                       // Анализ переменной типа ClassD  
     check.Check(try4);
     Console.WriteLine("\nAnalyzing MyStruct type variable:");
                       // Анализ переменной типа MyStruct  
     check.Check(try5);
     Console.WriteLine("\nAnalyzing boxed MyStruct type variable:"); 
                       // Анализ упакованной 
     check.Check(try6); 
     Console.ReadKey(); 
 }
开发者ID:sev-it,项目名称:asp.net,代码行数:29,代码来源:Program.cs


示例5: Main

 //Main_3_4_1
 public static void Main()
 {
     MyStruct ms = new MyStruct();
     MyClass mc = new MyClass();
     Console.WriteLine("IL Keywords.");
     Console.Read();
 }
开发者ID:anytao,项目名称:insidenet,代码行数:8,代码来源:ILDemo.cs


示例6: Main

    public static void Main()
    {
        //使用缺省构造函数创建对象:
        MyStruct Location1 = new MyStruct();
        MyClass Employee1 = new MyClass();

        //显示值:
        Console.WriteLine("Default values:");
        Console.WriteLine("\tStruct members: {0}, {1}",
           Location1.x, Location1.y);
        Console.WriteLine("\tClass members: {0}, {1}",
           Employee1.name, Employee1.id);

        //使用带有参数的构造函数创建对象:
        MyStruct Location2 = new MyStruct(10, 20);
        MyClass Employee2 = new MyClass(1234, "John Martin Smith");

        //显示值:
        Console.WriteLine("Assigned values:");
        Console.WriteLine("\tStruct members: {0}, {1}",
           Location2.x, Location2.y);
        Console.WriteLine("\tClass members: {0}, {1}",
           Employee2.name, Employee2.id);

        Console.ReadLine();
    }
开发者ID:Nagato23,项目名称:CsBasic,代码行数:26,代码来源:newTest.cs


示例7: DoSomething

        public static int DoSomething(string parameter1, string parameter2, ref MyStruct myStruct)
        {
            int result;
            MessageBox.Show(parameter1);
            MessageBox.Show(parameter2);

            try
            {
                /*
                myStruct.X = 5;
                myStruct.Y = 6.5;
                myStruct.Z = 25;

                myStruct.FirstName = "İsmail";
                myStruct.LastName = "Kocacan";

                myStruct.Array[0] = "value1";
                myStruct.Array[1] = "value2";
                myStruct.Array[2] = "value3";
                */

                myStruct.KeyValue[0].Key = "x key 1";
                myStruct.KeyValue[0].Value = "x value 1";
                MessageBox.Show("KeyValue : " + myStruct.KeyValue[0].Key);

                result = 1;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error");
                result = 0;
            }
            return result;
        }
开发者ID:ismailkocacan,项目名称:CppCSharpInterop,代码行数:34,代码来源:LibraryExport.cs


示例8: TestConstrainedMethodCalls

 static void TestConstrainedMethodCalls()
 {
     using (MyStruct s = new MyStruct())
     {
          ((Object)s).ToString();
     }
 }
开发者ID:bjjones,项目名称:coreclr,代码行数:7,代码来源:main.cs


示例9: Main

 public static void Main()
 {
     MyStruct newObj  = new MyStruct(),noNewObj;
     System.Console.WriteLine(newObj.x);
     //System.Console.WriteLine(noNewObj.x);thats thorws an error
     newObj.x=noNewObj.x=20;
     System.Console.WriteLine(newObj.x + "\n" + noNewObj.x);
 }
开发者ID:rags,项目名称:playground,代码行数:8,代码来源:struct.cs


示例10: Run

        public void Run()
        {
            MyStruct s = new MyStruct();
            s.b = "OK";

            MyDelegate dg = new MyDelegate(s.Test);
            dg();
        }
开发者ID:elasota,项目名称:clarity,代码行数:8,代码来源:TestStructDelegate.cs


示例11: UsingExample

        public static void UsingExample()
        {
            var obj = new MyStruct();
            obj = new MyStruct(false);

            obj.Flag = true;
            obj.SValue = "Hello, World!";

            MyStruct.IValue = 10;
        }
开发者ID:Menaver,项目名称:Drafts,代码行数:10,代码来源:Structs.cs


示例12: SumMSH

 private static int SumMSH(MyStruct[] ms)
 {
     int sum = 0;
     for (int i = 0; i < ms.Length; i++)
     {
         sum += ms[i].h; //Gives an AV
                         //sum += ms[i].b; //will not give an AV since offset is less than 8 bytes. 
     }
     return sum;
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:10,代码来源:osrAddovershot.cs


示例13: IsXGeater

    public static bool IsXGeater(MyStruct line)
    {
        if (line.v1.val > line.v2.val)
        {
            line = new MyStruct(line.v2, line.v1);
            return true;
        }

        return false;
    }
开发者ID:vkargov,项目名称:coreclr,代码行数:10,代码来源:GitHub_2610.cs


示例14: Main

	static void Main()
	{
		var i_fuenf = 5;
		PrintType(i_fuenf);

		var inst1 = new MyClass();
		PrintType(inst1);

		var inst2 = new MyStruct();
		PrintType(inst2);
	}
开发者ID:mkandroid15,项目名称:Samples,代码行数:11,代码来源:Boxing.cs


示例15: Test_Add

        public void Test_Add()
        {
            var svd = new SaveDataContainer ();
            var key = "Item0";
            var value = new MyStruct (1, 2f, "3");

            svd.Add (key, value);

            Assert.AreEqual (1, svd.ItemCount);
            Assert.AreEqual (1, svd.Items.Count ());
        }
开发者ID:weimingtom,项目名称:erica,代码行数:11,代码来源:TestSaveDataContainer.cs


示例16: Run

        public void Run()
        {
            MyStruct s = new MyStruct();
            TestApi.WriteLine(s.GetType().ToString());
            TestApi.WriteLine(s.ToString());

            MyEnum e = MyEnum.Default;
            //TestApi.WriteLine(e.CompareTo(e).ToString());
            TestApi.WriteLine(e.GetTypeCode().ToString());
            TestApi.WriteLine(e.ToString());
        }
开发者ID:elasota,项目名称:clarity,代码行数:11,代码来源:TestValueTypeCalls.cs


示例17: FillArchive

	//Create an archive of items to add custom data for them
	void FillArchive(){
		MyStruct temp = new MyStruct();
		// Item 1
		CustomItemCreator (temp, "item_test", "usar", "dar", "comentar", "mirar");
		myStructList.Add (temp);

		temp = new MyStruct();
		//Item 2
		CustomItemCreator(temp, "item_test2", "usar", "dar", "comentar");
		myStructList.Add (temp);
	}
开发者ID:Darthoul,项目名称:cena_gamejam,代码行数:12,代码来源:ItemArchive.cs


示例18: Test_GetOrCreate

        public void Test_GetOrCreate()
        {
            var svd = new SaveDataContainer ();
            var key = "Item0";
            var value = new MyStruct (1, 2f, "3");

            svd.GetOrCreate (key, value);

            Assert.AreEqual (1, svd.ItemCount);
            Assert.AreEqual (value, svd.Get (key));
            Assert.AreEqual (value, svd[key]);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:12,代码来源:TestSaveDataContainer.cs


示例19: Test

        public void Test()
        {
            var struct1 = new MyStruct {Age = 10, Name = "1234"};
            var struct2 = new MyStruct { Age = 10, Name = "1234" };

            Assert.AreEqual(struct1, struct2);

            var class1 = new MyClass { Age = 10, Name = "1234" };
            var class2 = new MyClass { Age = 10, Name = "1234" };

            Assert.AreNotEqual(class1, class2);
        }
开发者ID:ukionik,项目名称:EasyHelper,代码行数:12,代码来源:StructCompareTest.cs


示例20: Add

	public virtual MyStruct Add (int a, out int c, int b) {
		Console.WriteLine ("ADD");
		c = a + b;

		MyStruct res = new MyStruct ();

		res.a = a;
		res.b = b;
		res.c = c;
		
		return res;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:12,代码来源:remoting3.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# MyTarget类代码示例发布时间:2022-05-24
下一篇:
C# MyStringId类代码示例发布时间: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