Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4583786
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:15:48+00:00 2026-05-21T21:15:48+00:00

I’m working with the System.Web.Helpers.WebGrid in an ASP.NET MVC 3 Razor project, and I’m

  • 0

I’m working with the System.Web.Helpers.WebGrid in an ASP.NET MVC 3 Razor project, and I’m having trouble understanding why the format parameter for a WebGridColumn is a Func<dynamic, object>.

If I create a column like this…

grid.Column(
    format: x => string.Format("{0:d}", x.StartDate)
    );

…I don’t get strong typing on the StartDate property. If I try to get around it like this…

grid.Column(
    format: (MyObjectType x) => string.Format("{0:d}", x.StartDate)
    );

…I’m told at runtime that my lambda can’t be cast to a Func<dynamic, object>. Is there some way I can use a non-dynamic lambda here? Even if it’s just <object, object>?

(I’m in .NET 4.0, and Func<in T, out TResult> is supposed to be contravariant on T, but I’m confused about how covariance and contravariance work with dynamic.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:15:48+00:00Added an answer on May 21, 2026 at 9:15 pm

    As far as the type system is concerned, dynamic is the same as object.

    They cannot use a strongly-typed delegate because they don’t have a strongly-typed value to pass.

    Inside WebGrid, they get an Object from a PropertyDescriptor, and pass that to your delegate.

    Covariance won’t help here; had Func<YourType, string> been convertible to Func<object, string>, it would be possible to call it with any other type and get an invalid cast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.