message.cs

来自「C常用算法程序集,一部比较经典的程序算法合集」· CS 代码 · 共 44 行

CS
44
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace mychat1
{
    public struct Message
    {
        private readonly string userName;
        private readonly string content;
        private readonly DateTime postDate;

        public Message(string userName, string content)
        {
            this.userName = userName;
            this.content = content;
            this.postDate = DateTime.Now;
        }

        public Message(string content) : this("System", content) { }

        public string UserName
        {
            get { return userName; }
        }

        public string Content
        {
            get { return content; }
        }

        public DateTime PostDate
        {
            get { return postDate; }
        }

        public override string ToString()
        {
            return String.Format("{0}[{1}]:\r\n{2}\r\n", userName, postDate, content);
        }
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?