It's better and easier to eva line.



  • The lines in the file are recorded according to the following template:
    "# MNEM.UNIT VALUE DESCRIPTION"
    Here's an example:

      STOP.M                       2054.30 : Конечная  глубина
      STEP.M                          0.10 : Шаг квантования по глубине
      NULL.                        -999.25 : Нулевое значение
    

    How can it be easier and quick to clear the line and get the next one?

    string MNEM = "STOP";
    string UNIT = "M";
    string VALUE = "2054.30";
    string DESC = "Конечная глубина";
    

    MNEM may at the end contain a gap, but it certainly ends at ".
    UNIT does not contain gaps.
    VALUE may also contain points and gaps



  • I'd do it like that:

    string s = "  STOP.M                       2054.30 : Конечная  глубина  ";
    var _args = s.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
    

    if (_args.Count() != 2)
    throw new ArgumentException();

    var DESCRIPTION = _args[1];

    var MNEM = _args[0].Substring(0, _args[0].IndexOf("."));

    var args1 = _args[0].Substring(MNEM.Length).Trim();

    var UNIT = args1.Substring(0, args1.IndexOf(" "));

    var VALUE = args1.Substring(UNIT.Length).Trim();

    It's like this code goes under your format.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2