unity-atoms/Packages/Core/Editor/Extensions/StringExtensions.cs

18 lines
443 B
C#
Raw Normal View History

using System;
using System.Text;
2019-10-01 11:27:22 -04:00
namespace UnityAtoms
{
internal static class StringExtensions
{
public static int ToInt(this string str, int def)
{
int num;
return int.TryParse(str, out num) ? num : def;
}
public static string Repeat(this string str, int times)
=> times == 1 ? str : new StringBuilder(str.Length * times).Insert(0, str, times).ToString();
}
}