code/DataType/DataTypeInt1d.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;

namespace WR_Excel
{
    internal class DataTypeInt1d : DataType
    {
        public DataTypeInt1d(string desp, string name, string fieldType, int col) : base(desp, name, fieldType, col)
        {
        }

        public override EnumType Type => EnumType.Int1d;

        public override string TypeString => "int[]";
        public override string ConvertMethod => "Data2IntArr()";

        public override bool CheckValid(string text)
        {
            char splitchar = ',';
            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] < '0' || text[i] > '9')
                {
                    splitchar = text[i];
                    break;
                }
            }

            return StringHelper.IsIntArray(text, splitchar);
        }
        // 12_3_3 => [12,3,3]
        public override string GetJsonString(string text, int ident)
        {
            char splitchar = ',';
            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] < '0' || text[i] > '9')
                {
                    splitchar = text[i];
                    break;
                }
            }
            if (splitchar == ',')
                return $"[{text}]";

            return $"[{text.Replace(splitchar, ',')}]";
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。