chatmessage.cs

来自「a project create chat room in asp.net wi」· CS 代码 · 共 49 行

CS
49
字号
using System;

namespace ASPNETChat
{
   
    public class Message
    {
        #region Members
        public string user;
        public string msg;
        public MsgType type;
        #endregion

        #region Constructors
        public Message(string _user, string _msg, MsgType _type)
        {
            user = _user;
            msg = _msg;
            type = _type;
        }
        public Message(string _user, MsgType _type)
            :
                    this(_user, "", _type) { }
        public Message(MsgType _type) : this("", "", _type) { }
        #endregion

        #region Methods
        public override string ToString()
        {
            switch (this.type)
            {
                case MsgType.Msg:
                    return this.user + " says: " + this.msg;
                case MsgType.Join:
                    return this.user + " has joined the room";
                case MsgType.Left:
                    return this.user + " has left the room";
            }
            return "";
        }
        #endregion
    }


	public enum MsgType { Msg, Start, Join, Left, Action }

	
}

⌨️ 快捷键说明

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