3

It seems that in Views, there is limited libraries available (is it true?), see below: a screenshot showing the available methods for the IEnumerable

My question is how do I convert an IEnumerable to, say, an array or a list? I normally can use methods like ToArray(), ToList(), or Cast<T>() in a regular C# file, but they all seem to have disappeared when it comes to Views (in ASP.NET MVC).

0

1 Answer 1

11

<%@ import namespace='System.Linq' %>

You can also add your namespace in the Web.config, i.e.:

<system.web>
  <pages>
    <namespaces>
      <add namespace='System.Linq' />
    </namespaces>
  </pages>
</system.web>
Sign up to request clarification or add additional context in comments.

1 Comment

you probably want double quote?

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.