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;
|
}
|
|
}
|
}
|