コード例 #1
0
        private static SimulationObject ConvertItem(IEnumerable <string> vs)
        {
            var item  = new SimulationObject();
            var array = vs.ToArray();

            item.Name = array[0];

            if (array.Length < 2)
            {
                return(item);
            }

            if (byte.TryParse(array[1], out byte resultDigits))
            {
                item.Digits = resultDigits;
            }

            if (array.Length > 2)
            {
                if (double.TryParse(array[2], out double resultValue))
                {
                    item.Value = resultValue;
                }
            }

            return(item);
        }
コード例 #2
0
        private static string ConvertCsv(SimulationObject item)
        {
            var replacedName = item.Name != null ? $"\"{item.Name.Replace("\"", "\"\"")}\"" : $"\"\"";

            return($"{replacedName},{item.Digits},{item.Value}");
        }