util.cs

来自「一个比较简单的」· CS 代码 · 共 84 行

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

namespace AssetsSystem.Inc
{
    class Util
    {
        public static bool haveText(string str)
        {

            if (str == null || string.IsNullOrEmpty(str.Trim()))
            {
                return false;
            }
            return true;
            
        }

        public static bool isnumstr(String num)
        {
            if (!Util.haveText(num))
                return false;
            if (num.Length > 0)
            {
                if (num[0] == '-')
                {
                    num = num.Substring(1, num.Length);
                }
                String number = "0123456789";
                for (int i = 0; i < num.Length; i++)
                {
                    if (number.IndexOf(num[i]) == -1)
                    {
                        return false;
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }

        public static string Unhtmlcode(string str)
        {
            string newstr = "";
            if (str == null)
                return "";
            if (str.Length < 1)
                return "";
            newstr = str.Trim();
            newstr = newstr.Replace("&amp;", "&");
            newstr = newstr.Replace("&quot;", "\"");
            newstr = newstr.Replace("&nbsp;", " ");
            newstr = newstr.Replace("&lt;", "<");
            newstr = newstr.Replace("&gt;", ">");
            newstr = newstr.Replace("&#039;", "\'");
            newstr = newstr.Replace("<br/>", "\r\n");
            return newstr;
        }
        public static string HTMLcode(string TXTcode)
        {
            string newstr = "";
            if (TXTcode == null)
                return "";
            newstr = TXTcode.Trim();
            newstr = newstr.Replace("&", "&amp;");
            newstr = newstr.Replace("\"", "&quot;");
            newstr = newstr.Replace(" ", "&nbsp;");
            newstr = newstr.Replace("<", "&lt;");
            newstr = newstr.Replace(">", "&gt;");
            newstr = newstr.Replace("\'", "&#039;");
            newstr = newstr.Replace("\r\n", "<br/>");
            newstr = newstr.Replace("\n", "<br/>");
            newstr = newstr.Replace("\r", "<br/>");
            return newstr;

        }

    }
}

⌨️ 快捷键说明

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