C#结构函数

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

namespace Demo
{
    struct CustomerName
    {
        public string firstName, lastName;
        public string Name()
        {
            return firstName+" "+lastName;
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            CustomerName myCustomer;
            myCustomer.firstName = "Ji";
            myCustomer.lastName = "Qing";
            Console.WriteLine("客户的名字:{0}", myCustomer.Name());
            Console.ReadKey();
        }
    }
}

结构struct函数,有意思。可以尝试利用这个特性。

本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/6748212.html,如需转载请自行联系原作者

相关文章:

  • 2020-02-22
  • 2018-01-08
  • 2018-03-19
  • 2021-07-13
  • 2021-11-03
  • 2020-06-17
  • 2021-04-17
  • 2021-10-08
猜你喜欢
  • 2021-11-01
  • 2018-01-18
  • 2021-10-16
  • 2021-11-05
  • 2021-06-29
  • 2019-03-12
  • 2021-12-04
相关资源
相似解决方案