Indussky not in C# with steam



  • Hello! It's been a while since I started programming and studying c#, there's a need to use something like that not in the code, but I haven't found such examples on the Internet, so I'll ask you here.

    It's necessary to consider the line as a matter of urgency by defining the divider. The stroke is as follows:

    [Symbols to the divider][separator, some symbol][symbols after the divider].

    Symbols to the divider may include 0...9, E, e, +

    Please help counsel how this can be accomplished without using a scientist if-- (the only thing that has come to mind)

    string[] strs = inTextBox.Lines;
    for (int j = 0; j < strs.Length - 1; j++){
    if (strs[j] == "0") // 
    ... (куча других примеров разрешённых символов)
    else
    variable = strs[j];
    break;
    }
    


  • I think that'll suit you:

    char variable = "ваша строка".First(x => !"0123456789eE+-".Contains(x));
    

    Or it's a better option, but it's too much to see:

    const string symbols = "0123456789eE+-";
    const string str = "ваша строка";
    char variable;
    

    foreach (var s in str)
    {
    if (!symbols.Contains(s))
    {
    variable = s;
    break;
    }
    }



Suggested Topics

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