PSI.Common/StringHelper.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSI.Common
{
    public static class StringHelper
    {
        /// <summary>
        /// 将数字字符串转换为int
        /// </summary>
        /// <param name="strValue"></param>
        /// <returns></returns>
        public static int GetInt(this string strValue)
        {
            int reInt = 0;
            int.TryParse(strValue, out reInt);
            return reInt;
        }

        public static decimal GetDecimal(this string strValue)
        {
            decimal reInt = 0;
            decimal.TryParse(strValue, out reInt);
            return reInt;
        }

        public static int GetInt(this object oValue)
        {
            int reInt = 0;
            try
            {
                reInt = Convert.ToInt32(oValue);
            }
            catch
            {
                reInt = 0;
            }

            return reInt;
        }

        /// <summary>
        /// 把字符串按照分隔符转换成 List
        /// </summary>
        /// <param name="str">源字符串</param>
        /// <param name="speater">分隔符</param>
        /// <param name="toLower">是否转换为小写</param>
        /// <returns></returns>
        public static List<string> GetStrList(this string str, char speater, bool toLower)
        {
            List<string> list = new List<string>();
            string[] ss = str.Split(speater);
            foreach (string s in ss)
            {
                if (!string.IsNullOrEmpty(s) && s != speater.ToString())
                {
                    string strVal = s;
后面还有 197 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。