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

C# Derived类代码示例

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

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



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

示例1: RefreshingEntityDerivedFromAbstractClass

        public void RefreshingEntityDerivedFromAbstractClass()
        {
            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    var d = new Derived();
                    session.Store(d);
                    session.SaveChanges();

                    using (var seperateSession = store.OpenSession())
                    {
                        var loaded = seperateSession.Load<Derived>(d.Id);
                        Assert.NotNull(loaded);
                        Assert.Empty(loaded.Foos);

                        loaded.AddFoo(new Foo() { Name = "a" });
                        seperateSession.SaveChanges();
                    }

                    session.Advanced.Refresh(d);
                    Assert.Single(d.Foos);
                }
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:25,代码来源:RefreshModifiedDocument.cs


示例2: Run

        public void Run()
        {
            // Array Covariance
            // http://msdn.microsoft.com/en-us/library/aa664572(v=vs.71).aspx
            /*
             * For any two reference-types A and B, if an implicit reference conversion (Section 6.1.4) or explicit reference conversion (Section 6.2.3)
             * exists from A to B, then the same reference conversion also exists from the array type A[R] to the array type B[R],
             * where R is any given rank-specifier (but the same for both array types).
             * This relationship is known as array covariance.
             * Array covariance in particular means that a value of an array type A[R] may actually be a reference to an instance of an array type B[R],
             * provided an implicit reference conversion exists from B to A.
             *
             * Because of array covariance, assignments to elements of reference type arrays include a run-time check that ensures that the value
             * being assigned to the array element is actually of a permitted type (Section 7.13.1).
             * */

            Base[] baseArray = new Base[1];
            Derived[] derivedArray = new Derived[] { new Derived() };

            // array element assignment is covariant
            baseArray[0] = new Derived();
            baseArray[0] = new OtherDerived();

            // This assignment is not type safe but it is allowed
            baseArray = derivedArray;
            baseArray[0] = new Derived();
            // ArrayTypeMismatchException at RUNTIME
            baseArray[0] = new OtherDerived();

            populate(derivedArray);
        }
开发者ID:jdavis-klick,项目名称:variance-tutorial-examples,代码行数:31,代码来源:11_ArrayExample.cs


示例3: DoIt

        public void DoIt()
        {
            var stringArray1 = new string[] {"A", "B", "C"};
            Array.Reverse(stringArray1);

            string[] stringArray2 = {"Hello", "World"};
            Array.Sort(stringArray2);

            var r = stringArray2.Concat(stringArray1);
            foreach(var i in r)
            {
                Console.Out.WriteLine(">>> " + i);
            }

            var d = new Derived();
            Console.Out.WriteLine("Value: " + d.Value);

            var list = new List<string>
                           {
                               "ghi",
                               "abc",
                               "rhj"
                           };
            list.Sort((s, s1) => string.Compare(s, s1) * -1);

            foreach (var i in list)
            {
                Console.Out.WriteLine("> " + i);
            }
        }
开发者ID:lly123,项目名称:CSharp,代码行数:30,代码来源:ArrayOperation.cs


示例4: Main

    public static void Main ()
    	{	    
	    //Base[] derivedArray = new Base [10];
    	    //Base[] baseArray = new Derived [10];
	    Derived[] derivedArray = new Derived [10];
	    test (derivedArray);
    	}
开发者ID:ppatoria,项目名称:SoftwareDevelopment,代码行数:7,代码来源:TestCovariance+(1).cs


示例5: Main

 static void Main()
 {
     Base B = new Base();
     Derived D = new Derived();
     B.Message();
     D.Message();
 }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:7,代码来源:Program.cs


示例6: Run

 public void Run()
 {
     var b = new Base();
     b.Execute();
     b = new Derived();
     b.Execute();
 }
开发者ID:rrsc,项目名称:ProgrammingInCSharp,代码行数:7,代码来源:HidingAMethodWithTheNewKeyword.cs


示例7: DemoVanInterface

        public void DemoVanInterface()
        {
            IBankAccount account = new Derived();
            account.Withdraw(10m);

            Console.WriteLine($"Balance: {((Base)account).Balance}");
        }
开发者ID:riezebosch,项目名称:cnetin,代码行数:7,代码来源:UnitTest1.cs


示例8: Main

    public static void Main(string[] args)
    {
        var br = new BaseResult();
        var dr = new DerivedResult();

        var bas = new Base();
        var derived = new Derived();

        bas.Method();
        bas.MethodWithParameter1(br);
        bas.MethodWithParameter1(dr);
        bas.MethodWithParameter2(dr);

        bas = derived;
        bas.Method();
        bas.MethodWithParameter1(br);
        bas.MethodWithParameter1(dr);
        bas.MethodWithParameter2(dr);

        derived.Method();
        derived.MethodWithParameter1(br);
        derived.MethodWithParameter1(dr);
        derived.MethodWithParameter2(br);
        derived.MethodWithParameter2(dr);
    }
开发者ID:cbsistem,项目名称:JSIL,代码行数:25,代码来源:Issue368.cs


示例9: Main

        static void Main()
        {
            var b = new Base("A");
            var d = new Derived("B", "C");

            TestLogger.Log("Static method calls...");
            TestLogger.Log(Base.S("D")); // "DBS"
            TestLogger.Log(Derived.S("E")); // "EDS"
            TestLogger.Log("Instance method calls...");
            TestLogger.Log(b.I("F")); // "AFBI";
            TestLogger.Log(d.I("G")); // "BCGDI";
            TestLogger.Log("Virtual method calls...");
            TestLogger.Log(b.V("H")); // "AHBV";
            TestLogger.Log(((Base)d).V("I")); // "BCIDV";
            TestLogger.Log("Interface method calls...");
            TestLogger.Log(((IMN)b).M("J")); // "AJBM";
            TestLogger.Log(((IMN)d).M("K")); // "BCKDM";
            TestLogger.Log(((IOP)b).O("L")); // "ALBO";
            TestLogger.Log(((IOP)d).O("M")); // "BMBO";
            TestLogger.Log("Virtual interface method calls...");
            TestLogger.Log(((IMN)b).N("N")); // "ANBN";
            TestLogger.Log(((IMN)d).N("O")); // "BCODN";
            TestLogger.Log(((IOP)b).P("P")); // "APBP";
            TestLogger.Log(((IOP)d).P("Q")); // "BCQDP";
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:25,代码来源:Program.cs


示例10: run

  void run()
  {
    if (director_primitives.PrintDebug) Console.WriteLine("------------ Start ------------ ");

    Caller myCaller = new Caller();

    // test C++ base class
    using (Base myBase = new Base(100.0))
    {
      makeCalls(myCaller, myBase);
    }

    if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");

    // test vanilla C++ wrapped derived class
    using (Base myBase = new Derived(200.0))
    {
      makeCalls(myCaller, myBase);
    }

    if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");

    // test director / C# derived class
    using (Base myBase = new CSharpDerived(300.0))
    {
      makeCalls(myCaller, myBase);
    }

    if (director_primitives.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
  }
开发者ID:Reticulatas,项目名称:MochaEngineFinal,代码行数:30,代码来源:director_primitives_runme.cs


示例11: Execute

        public void Execute()
        {
            var assembly = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "protobuf-net.dll"));
            var derived = new Derived()
            {
                BaseFirstProperty = "BaseFirst",
                BaseSecProperty = "BaseSec",
                DerivedFirstProperty = "DerivedFirst"
            };

            var reflectionSerializer = assembly.GetType("ProtoBuf.Serializer");
            var getTypeSerializer = typeof(Serializer);

            var reflectionMethods = reflectionSerializer.GetMethods(BindingFlags.Static | BindingFlags.Public);
            var reflectionGenericMethodInfo = reflectionMethods.First<MethodInfo>(method => method.Name == "SerializeWithLengthPrefix");
            var reflectionSpecificMethodInfo = reflectionGenericMethodInfo.MakeGenericMethod(new Type[] { derived.GetType() });

            var getTypeMethods = getTypeSerializer.GetMethods(BindingFlags.Static | BindingFlags.Public);
            var getTypeGenericMethodInfo = getTypeMethods.First<MethodInfo>(method => method.Name == "SerializeWithLengthPrefix");
            var getTypeSpecificMethodInfo = getTypeGenericMethodInfo.MakeGenericMethod(new Type[] { derived.GetType() });

            var reflectionStream = new MemoryStream();
            var getTypeStream = new MemoryStream();
            reflectionSpecificMethodInfo.Invoke(null, new object[] { reflectionStream, derived, PrefixStyle.Base128 });
            getTypeSpecificMethodInfo.Invoke(null, new object[] { getTypeStream, derived, PrefixStyle.Base128 });

            Assert.AreEqual(37, (int)reflectionStream.Length, "loaded dynamically");
            Assert.AreEqual(37, (int)getTypeStream.Length, "loaded statically");
            
        }
开发者ID:highskillz,项目名称:mgravell--protobuf-net,代码行数:30,代码来源:SO14540862.cs


示例12: MainMethod

 public static int MainMethod(string[] args)
 {
     dynamic d = new Derived();
     short x = d;
     if (x == short.MaxValue)
         return 0;
     return 1;
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:8,代码来源:Conformance.dynamic.overloadResolution.Operators.2class2operators.conversion.cs


示例13: Given

        protected override void Given()
        {
            _result = new Derived();

            _calculation = new Calculation(new Variable("Grasp", "Output", typeof(Base)), Expression.Constant(_result));

            _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculation });
        }
开发者ID:bwatts,项目名称:Grasp,代码行数:8,代码来源:CompileWithDerivedType.cs


示例14: Main

 static void Main()
 {
     Base B = new Base();
     Derived D = new Derived();
     B.a = 1234;
     D.a = 5.678;
     Console.WriteLine(B.a);
     Console.WriteLine(D.a);
 }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:9,代码来源:Program.cs


示例15: Factory

 void Factory(out Base b)
 {
     // covariant assignment
     if (DateTime.Now.Year > 2013) {
         b = new Derived();
     } else {
         b = new OtherDerived();
     }
 }
开发者ID:jdavis-klick,项目名称:variance-tutorial-examples,代码行数:9,代码来源:13_OutExamples.cs


示例16: Main

        static void Main(string[] args)
        {
            Base d = new Derived();     //создаем экземпляр производного класса - в переменную БАЗОВОГО КЛАССА !!

            d.DoSomething();            //вызываем метод производного класса - (он переопределен)

            Console.WriteLine( d.MyProperty );  //доступ к свойству производного класса - (переопределено)
            Console.ReadKey();
        }
开发者ID:akmaplus,项目名称:My_sources_cs,代码行数:9,代码来源:b6.cs


示例17: Oops

 static void Oops(Derived d)
 {
     Console.WriteLine(d);
     Console.WriteLine(d.i);
     Console.WriteLine(d.j);
     Console.WriteLine(d.k);
     d.i = 0x77777777;
     d.j = 0x77777777;
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:9,代码来源:DevDiv2_8863.cs


示例18: DemoVanOverrideVanMethod

        public void DemoVanOverrideVanMethod()
        {
            Base b = new Base();
            Derived d = new Derived();

            Console.WriteLine(b.CalculateInterest(100m));

            Console.WriteLine(d.CalculateInterest(100m));
        }
开发者ID:riezebosch,项目名称:cnetin,代码行数:9,代码来源:UnitTest1.cs


示例19: Can_deserialize_private_set_in_base_class

        public void Can_deserialize_private_set_in_base_class()
        {
            var derived = new Derived();
            derived.Set("test");

            string serialized = derived.ToJson();
            var deserialized = serialized.FromJson<Derived>();

            Assert.That(deserialized.Value, Is.EqualTo("test"));
        }
开发者ID:ServiceStack,项目名称:ServiceStack.Text,代码行数:10,代码来源:InheritanceTests.cs


示例20: Main

	public static int Main ()
	{
		var d = new Derived ();
		d.Print ();

		if (d.i != 90)
			return 1;

		return 0;
	}
开发者ID:afaerber,项目名称:mono,代码行数:10,代码来源:test-anon-94.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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