Ejemplo n.º 1
0
        public string Delete(int index)
        {
            if (Raw.Length == 0)
            {
                return(Raw);
            }

            // 小数は置換
            if (index > 0 && index >= Raw.Length)
            {
                index -= 1;
            }

            if (index > 0)
            {
                var subChar = Raw.Substring(index, 1);

                if (subChar == ".")
                {
                    return(Raw);
                }
            }

            if (IncludeInteger(index))
            {
                // 整数は消せばいい
                Raw = Raw.Remove(index, 1);

                if (IntegerPartText == "")
                {
                    Raw = Raw.Insert(0, '0'.ToString());
                }
            }
            else if (IncludeDecimal(index))
            {
                Raw = Raw.Remove(index, 1).Insert(index, "0");
            }

            return(Raw);
        }
Ejemplo n.º 2
0
        public string InsertOrReplace(char digit, int index)
        {
            if (IncludeInteger(index))
            {
                // 整数は追加
                Raw = Raw.Insert(index, digit.ToString());
            }
            else if (IncludeDecimal(index))
            {
                // 小数は置換
                if (index >= Raw.Length)
                {
                    index -= 1;
                }

                Raw = Raw.Remove(index, 1).Insert(index, digit.ToString());
            }

            // 整数値に不要な数値があるときは、削除する
            TrimInteger();

            return(Raw);
        }