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

  • SEARCH
  • Home
  • 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 6933675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:51:46+00:00 2026-05-27T11:51:46+00:00

NEWBIE, Newbie, newbie question, sorry. I’ve just started programming in C# (coming long ago

  • 0

NEWBIE, Newbie, newbie question, sorry. I’ve just started programming in C# (coming long ago from the strongly typed world of c++). Its fun to be back programming but I see in the global.asax file the routes.MapRoute method that takes some kind of untyped object as the third and fourth parameter. Both instantiated the same, but possibly as two different types.

route.MapRoute( p1, p2, new { controller = "Home", Action = "Index" }, new {} );

Surprisingly, everything works well. But, I now want to access the 3rd parameter in a helper and it is coming in as an object type. I don’t have any problem with casting the object type to whatever type of object it is, but I don’t have a clue what it was instantiated as (nor can I find any docs that say more than object). Along the same line, how on earth does it know how to deal with something like ‘controller’ which exists inside the typed/untyped object? Now I have an unknown object type with unknown/varying property types inside. I would guess var?

Just as a comment on these assumptions made by the compiler, when I see examples of unit tests created just to make sure the loosely typed stuff is included and correctly spelled and typed, I lose confidence in the value of the loosely typed approach. Am I missing something?

  • 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-27T11:51:46+00:00Added an answer on May 27, 2026 at 11:51 am

    the routes.MapRoute method that takes some kind of untyped object

    It’s not an untyped object; the object has a type, only it is an anonymous type.

    how on earth does it know how to deal with something like ‘controller’ which exists inside the typed/untyped object?

    It examines the object using reflection

    But, I now want to access the 3rd parameter in a helper and it is coming in as an object type. I don’t have any problem with casting the object type to whatever type of object it is, but I don’t have a clue what it was instantiated as

    The scope of anonymous types is limited to the method where they are used. If you need to reuse this type somewhere else, use a named type instead of an anonymous type.

    Just to make it clear: the use of anonymous types doesn’t “break” strong typing. It’s just that in some cases you only need the type in one place, so you don’t want to declare a type that you will only use once. In the case of the MapRoute method, the use of an anonymous type is just a convenience, as it’s easier to declare an instance of an anonymous type than to manually create a dictionary (list of key/value pairs)

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

Sidebar

Related Questions

sorry for the newbie question but, I'm new to programming.. I want to check
preemptive sorry for the newbie question. I'm trying to load strings from a resource
Sorry for this newbie question, just got starting. I want a simple program to
Just starting with php and sorry if this is a newbie question but i'm
Sorry for the second newbie question, I'm a developer not a sysadmin so this
sorry for a newbie question.. but Service by it's defenision meaning the same as
I'm really new to VSTO so sorry if this is a newbie question. I'm
first of all, sorry if that question is dumb but I´m a total newbie
Newbie question: I just installed VisualSVN Server and created a repository. I noticed that
Sorry about this newbie question. Is there a way to execute multiple sentences at

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.