zoukankan      html  css  js  c++  java
  • 结构体

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace TestStruct
    {
        /// <summary>
        /// 声明结构
        /// </summary>
        public struct Name
        {
            private string fname, mname, lname;
    
            public Name(string first, string middle, string last)
            {
                this.fname = first;
                this.mname = middle;
                this.lname = last;
            }
    
            public string FirstName
            {
                get { return fname; }
                set { fname = value; }
            }
    
            public string MiddleName
            {
                get { return mname; }
                set { mname = value; }
            }
    
            public string LastName
            {
                get { return lname; }
                set { lname = value; }
            }
    
            /// <summary>
            /// 重写了ToString方法
            /// </summary>
            /// <returns>重写的值,复杂返回哈希值!</returns>
            public override string ToString()
            {
                
                return string.Format("{0}.{1}.{2}", fname, mname, lname);
            }
    
            public string Initials()
            {
                return string.Format("{0}.{1}.{2}", fname.Substring(0, 1).ToUpper(),
                                                  mname.Substring(0, 1).ToUpper(),
                                                  lname.Substring(0, 1).ToUpper());
            }
    
        }
    
        class Program
        {     
            static void Main(string[] args)
            {
                Name myName = new Name("Michael","Mason","McMillan");
    
                string fullName = myName.ToString();
                string inits = myName.Initials();
    
                Console.WriteLine(myName);
                Console.WriteLine(fullName);
                Console.WriteLine(inits);
            }
        }
    }
    


  • 相关阅读:
    Win10系列:VC++绘制几何图形3
    Win10系列:VC++绘制几何图形2
    二进制的编码
    win10下更新anaconda和pip源
    在win10上安装FFmpeg
    git设置代理模式,仅为github设置代理
    python3的pip3安装
    texlive2019安装
    ubuntu中安装python3和pip
    macbook安装win10
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3036583.html
Copyright © 2011-2022 走看看