none
How to Check for bigest Numeric Value in a Text Box with many Values RRS feed

  • Frage

  • i have a text box with many numeric values from deferent columns in a data grid i would like to check from the highest numeric value `in the textbox to the least and change these specific values to "1", "2" or "H1", "H2" etc. until each value is replaced with there ranking from highest to lowest value and save each back to the data grid according to their columns is it possible ? and can some one help me out please.

    Montag, 25. Januar 2021 01:38

Antworten

  • Hi,
    hier mal ein Auszug aus einer Konsolendemo zu deiner Frage:

          internal void Execute()
          {
            string input = "283.40 366.10 397.50 909.50 387.60 356.90 345.60 400.20 371.50 335.00 1,126.90 289.40 467.20";
            string result = ConvertData(input);
            Console.WriteLine(result);
          }
    
          private string ConvertData(string inp)
          {
            var arr = inp.Split(' ');
            var res = from v in arr orderby Convert.ToDouble(v, CultureInfo.InvariantCulture) descending select $"H{v}";
            return string.Join(" ", res);
          }

    Das Ergebnis ist dann:

    H1,126.90 H909.50 H467.20 H400.20 H397.50 H387.60 H371.50 H366.10 H356.90 H345.60 H335.00 H289.40 H283.40


    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    Montag, 25. Januar 2021 06:35