📄 operator.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
/// <summary>
/// 运算符类,作为一种扩展性,独立封装
/// </summary>
class Operator
{
/// <summary>
/// 运算符
/// </summary>
public char Symbol;
/// <summary>
/// 是否有交换律
/// </summary>
public bool Exchangable;
/// <summary>
/// 优先级,值越大越有效
/// </summary>
public int Priority;
public Operator(char symbol, bool exchangable, int priority)
{
Symbol = symbol;
Exchangable = exchangable;
Priority = priority;
}
public static Operator Add = new Operator('+', true, 0);
public static Operator Sub = new Operator('-', false, 0);
public static Operator Mul = new Operator('*', true, 1);
public static Operator Div = new Operator('/', false, 1);
static List<Operator> operators = null;
public static List<Operator> Operators
{
get
{
if (operators == null)
{
operators = new List<Operator>(4);
operators.Add(Add);
operators.Add(Sub);
operators.Add(Mul);
operators.Add(Div);
}
return operators;
}
}
public override string ToString()
{
return Symbol.ToString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -