Get Max value from list

Hi,

how can i get the max value from a list in c#?
The following does not work

List < int> list = new List<int>{1,2,4,5,8};
int max = list.Max();

using System.Linq;

Hi @flokart,

This test command works as expected:

using Rhino;
using Rhino.Commands;
using System.Collections.Generic;
using System.Linq;

namespace TestCs7
{
  public class TestMax : Command
  {
    public override string EnglishName => "TestMax";

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var numbers = new List<int> { 1, 8, 3, 2 };
      var msg = $"Max: {numbers.Max()}";
      RhinoApp.WriteLine(msg);
      return Result.Success;
    }
  }
}

What am I missing?

– Dale

As I understand his second post, he was not using the Linq namespace.

Yep sorry