25 lines
638 B
C#
25 lines
638 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TempTask.WebEntry.Tools
|
|
{
|
|
/// <summary>
|
|
/// 扩展
|
|
/// </summary>
|
|
public static class Extension
|
|
{
|
|
/// <summary>
|
|
/// 将字符串转换为整数
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <param name="defaultValue">转换失败时的默认值</param>
|
|
/// <returns></returns>
|
|
public static int ToInt(this string str, int defaultValue = int.MinValue)
|
|
{
|
|
return int.TryParse(str, out int i) ? i : defaultValue;
|
|
}
|
|
}
|
|
}
|