移动系统liao
2024-07-30 306ab8865840b2637590abb6e670e5614446f24d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace CoreCms.Net.Utility.Extensions
{
    /// <summary>
    /// 字符串扩展
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// str 转int
        /// </summary>
        /// <param name="value"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static int ToInt32OrDefault(this string value, int defaultValue = 0)
        {
            if (int.TryParse(value, out int result))
            {
                return result;
            }
            return defaultValue;
        }
        
    }
}