0

I have a program which is giving me a custom list of numbers 'NumberList'. I converted that list into a custom array with the ultimate goal of converting it to an int array. However, the logic I am using is not letting me convert and giving me following error:

CS0411 C# The type arguments for method cannot be inferred from the usage. Try specifying the type arguments explicitly.

Can anyone please help me with this?

public static void Main(string[] args)
{
     if (!string.IsNullOrEmpty(Btn()))
     {
          var manager = new NumberManager(Btn());
          var res = manager.Execute();

          NumberWith[] NWArray = manager.NumbersList.ToArray();

          var intArray =  Array.ConvertAll( NWArray, int.Parse);
     }
}
11
  • 4
    Welcome to Stack Overflow. Please edit your question and add the code which defines NumberWith. Commented Oct 28, 2019 at 18:00
  • 2
    What does the object look like? Additionally... Why to an Array at all, and not just List<T> for each step? Commented Oct 28, 2019 at 18:00
  • 1
    it IS answerable. The problem is that numberswith is an object with properties. The final line of code needs to be changed to be NWArray.someproperty Commented Oct 28, 2019 at 18:12
  • 1
    What does the NumberManaer and NumberWith look like and more importantly what does NumbersList return? Commented Oct 28, 2019 at 18:49
  • 1
    Side Note: Why is Btn() called twice? Shouldn't you call once and cache the results? Commented Oct 28, 2019 at 18:50

1 Answer 1

1

Try

var intArray =  manager.NumbersList.Select((item)=> item.Number).ToArray();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.