BuildingCoder.CmdSetRoomOccupancy.BumpStringSuffix C# (CSharp) Method

BumpStringSuffix() static private method

Analyse the given string. If it ends in a sequence of digits representing a number, return a string with the number oincremented by one. Otherwise, return a string with a suffix "1" appended.
static private BumpStringSuffix ( string s ) : string
s string
return string
        static string BumpStringSuffix( string s )
        {
            if( null == s || 0 == s.Length )
              {
            return "1";
              }
              if( null == _digits )
              {
            _digits = new char[] {
              '0', '1', '2', '3', '4',
              '5', '6', '7', '8', '9'
            };
              }
              int n = s.Length;
              string t = s.TrimEnd( _digits );
              if( t.Length == n )
              {
            t += "1";
              }
              else
              {
            n = t.Length;
            n = int.Parse( s.Substring( n ) );
            ++n;
            t += n.ToString();
              }
              return t;
        }