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


C# MyClass类代码示例

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


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

示例1: Main

   static public void Main () 
   {
      I i = new MyClass();

      i.MyEvent += new MyDelegate(f);
      i.FireAway();
   }
开发者ID:hattya,项目名称:ctags,代码行数:7,代码来源:input.cs

示例2: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: The key to be remove is a custom class");

        try
        {
            IDictionary iDictionary = new Dictionary<object,object>();
            MyClass mc = new MyClass();
            int value = TestLibrary.Generator.GetInt32(-55);
            iDictionary.Add(mc, value);
            iDictionary.Remove(mc);
            if (iDictionary.Contains(mc))
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected ");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:27,代码来源:idictionaryremove.cs

示例3: OrderByWithAttributeShouldStillWork

		public void OrderByWithAttributeShouldStillWork()
		{
			using (var store = NewDocumentStore())
			{
				const int count = 1000;

				using (var session = store.OpenSession())
				{
					for (var i = 0; i < count; i++)
					{
						var model = new MyClass
						{
							ThisWontWork = i,
							ThisWillWork = i
						};
						session.Store(model);
					}
					session.SaveChanges();
				}

				using (var session = store.OpenSession())
				{
					var orderedWithoutAttribute = session.Query<MyClass>().OrderBy(x => x.ThisWillWork).Take(count).ToList();
					var orderedWithAttribute = session.Query<MyClass>().OrderByDescending(x => x.ThisWontWork).Take(count).ToList();

					Assert.Equal(count, orderedWithoutAttribute.Count);
					Assert.Equal(count, orderedWithAttribute.Count);

					for (var i = 1; i <= count; i++)
					{
						Assert.Equal(orderedWithoutAttribute[i - 1].ThisWontWork, orderedWithAttribute[count - i].ThisWontWork);
					}
				}
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:35,代码来源:RenamedProperty.cs

示例4: NegTest1

    public bool NegTest1()
    {
        bool retVal = true;

        int count;
        bool actualValue;
        bool expectedValue;

        count = 20;
        expectedValue = count >= c_CRITERIA;

        TestLibrary.TestFramework.BeginScenario("NegTest1: call the method Predicate.BeginInvoke asynchronously");
        try
        {
            MyClass myClass = new MyClass(count);
            Predicate<int> selector = myClass.IsGreatEnough;
            IAsyncResult asyncResult = selector.BeginInvoke(c_CRITERIA, null, null);
            actualValue = selector.EndInvoke(asyncResult);
            retVal = false;
            TestLibrary.TestFramework.LogError("003", "NotSupportedException expected");
        }
        catch (NotSupportedException)
        {
            //expected
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:32,代码来源:predicatebegininvoke.cs

示例5: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: The generic type is type of string");

        try
        {
            string[] strArray = { "Hello", "wor", "l", "d" };
            List<string> listObject = new List<string>(strArray);
            MyClass myClass = new MyClass();
            Action<string> action = new Action<string>(myClass.joinstr);
            listObject.ForEach(action);
            if (myClass.result != "Helloworld")
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected,sum is: " + myClass.sum);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:27,代码来源:listforeach.cs

示例6: 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

示例7: Method1

 static void Method1(int number, string text, MyClass myClass)
 {
     number = 10;
       text = "new string";
       myClass = new MyClass(true);
     //same
 }
开发者ID:AdriVanHoudt,项目名称:School,代码行数:7,代码来源:ParameterModifiersProgram.cs

示例8: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        int count;
        bool actualValue;
        bool expectedValue;

        count = 99;
        expectedValue = count >= c_CRITERIA;

        TestLibrary.TestFramework.BeginScenario("PosTest2: call the method Predicate.EndInvoke synchronously");
        try
        {
            MyClass myClass = new MyClass(count);
            Predicate<int> selector = myClass.IsGreatEnough;
            actualValue = selector(c_CRITERIA);
            if (actualValue != expectedValue)
            {
                TestLibrary.TestFramework.LogError("003", "ExpectedValue(" + expectedValue + ") != ActualValue(" + actualValue + ")");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:30,代码来源:predicateinvoke.cs

示例9: MainMethod

 public static int MainMethod(string[] args)
 {
     MyClass mc = new MyClass();
     dynamic d = mc.Prop;
     d(3); //We invoke the dynamic delegate
     return Test.s_status ? 0 : 1;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:Conformance.dynamic.statements.invokeDynamic.cs

示例10: 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

示例11: Main

        static void Main(string[] args)
        {
            MyClass<string> cl = new MyClass<string>();

            cl.Add("Dan");
            cl.Add("Bob");
            cl.Add("Max");
            cl.Add("Nina");
            cl.Add("Marina");
            cl.Add("Nadya");
            cl.Add("Vanya");
            //cl.Add("Vova");
            //cl.Add("Vasya");

            foreach (string temp in cl)
                Console.WriteLine(temp);

            Console.WriteLine(cl.Count);
            Console.WriteLine();

            Console.WriteLine(cl[4]);
            Console.WriteLine();

            cl.Remove("Bob");
            foreach (string temp in cl)
                Console.WriteLine(temp);
            Console.WriteLine(cl.Count);
            Console.ReadLine();
        }
开发者ID:DenisBV,项目名称:Nix.Task.2b,代码行数:29,代码来源:Program.cs

示例12: test2

        public void test2()
        {
            int a = 2;
            int b = 2;

            int c, d, result;

            MyClass myClass1 = new MyClass();
            MyClass myClass2 = new MyClass();

            while ((a > 1) && (b > 1))
            {
                c = 3;
                d = 1;

                while (d < b)
                {
                    result = AddAll(myClass1, a, b, c, d, myClass2);

                    AssertEquals(8, result);

                    b = 0;
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:25,代码来源:TestWhile.cs

示例13: GetValue

        public void GetValue()
        {
            var mc = new MyClass
            {
                MyProperty = 100,
                Depth2 = new Depth2
                {
                    MyProperty = 1000,
                    Depth3 = new Depth3
                    {
                        MyProperty = 10000
                    }
                }
            };

            {
                Expression<Func<MyClass, int>> selector = x => x.MyProperty;
                var accessor = ReflectionAccessor.Create(selector.Body as MemberExpression);
                accessor.GetValue(mc).Is(100);
            }

            {
                Expression<Func<MyClass, int>> selector = x => x.Depth2.MyProperty;
                var accessor = ReflectionAccessor.Create(selector.Body as MemberExpression);
                accessor.GetValue(mc).Is(1000);
            }

            {
                Expression<Func<MyClass, int>> selector = x => x.Depth2.Depth3.MyProperty;
                var accessor = ReflectionAccessor.Create(selector.Body as MemberExpression);
                accessor.GetValue(mc).Is(10000);
            }
        }
开发者ID:uzzu,项目名称:UniRx,代码行数:33,代码来源:ReflectionAccessorTest.cs

示例14: InitObj

 public static bool InitObj()
 {
     MyClass c = new MyClass();
     return c.x == c.y &&
            c.y == c.z &&
            c.z == 0;
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:7,代码来源:InitObj.cs

示例15: Main

		static void Main(string[] args)
		{
			MyClass mc = new MyClass(); // Create an instance of the class.
			Type t = mc.GetType(); // Get the Type object from the instance.

			// IsDefined
			bool isDefined = // Check the Type for the attribute.
			t.IsDefined(typeof(ReviewCommentAttribute), false);
			if( isDefined )
			{
				Console.WriteLine("ReviewComment is applied to type {0}", t.Name);
			}
			
			// GetCustomAttributes
			object[] AttArr = t.GetCustomAttributes( false );
			foreach ( Attribute a in AttArr )
			{
				ReviewCommentAttribute attr = a as ReviewCommentAttribute;
				if ( null != attr )
				{
					Console.WriteLine( "Description : {0}", attr.Description );
					Console.WriteLine( "Version Number : {0}", attr.VersionNumber );
					Console.WriteLine( "Reviewer ID : {0}", attr.ReviewerID );
				}
			}
		}
开发者ID:creating2000,项目名称:Codes,代码行数:26,代码来源:GetCustomAttributes.cs


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