zoukankan      html  css  js  c++  java
  • 链式编程example

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Person p = new Person();
                //链式编程
                p.Sayhi().Hello();
                Console.ReadKey();
            }
        }
        class Person
        {
            public int Age { get; set; }
            public string  Name { get; set; }
            public Person Sayhi()
            {
                Console.WriteLine(
                    "hhaha");
                //链式编程的关键:执行方法之后,返回当前对象.
                return this;
            }
            public Person Hello()
            {
                Console.WriteLine(
                    "hello");
                return this;
            }
        }
    }

  • 相关阅读:
    Maven的生命周期
    Maven坐标
    IDEA配置maven
    IDEA配置tomcat
    重写父类方法
    类的继承
    内部类
    static关键字
    线程相关知识
    数组
  • 原文地址:https://www.cnblogs.com/nqsan/p/3216211.html
Copyright © 2011-2022 走看看