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 7979267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:43:56+00:00 2026-06-04T09:43:56+00:00

In his book, Jon Skeet refers to 7 restrictions on implicit typing. I need

  • 0

In his book, Jon Skeet refers to 7 restrictions on implicit typing. I need clarification on the last two:

A. The type you want the variable to have is the compile-time type of the initialization expression.
B. The initialization expression doesn’t involve the variable being declared.

The book covers material in the same order it was released (C# 2 before C# 3). At this point C# 4 has not been introduced so I make the assumption that A does not refer to dynamic. So, when would the compile-time type be different from the execution time type of the initialization expression?

As for B, when can an initialization expression involve the variable being declared?

  • 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-06-04T09:43:57+00:00Added an answer on June 4, 2026 at 9:43 am

    Regarding B, Henk gave a perfect answer (edit: it’s now removed), although I find it peculiar that int x = x = 1; compiles. (I would’ve thought x isn’t considered declared until after the initializer. Oh, well.) His answer was:

    int x = x = 1;   // Compiles
    var y = y = 2;   // Does not compile
    

    Regarding A and your question as to when the compile time type wouldn’t match the execution time type, here’s an example where they would differ:

    var foo = fooFactory.GetFoo();
    

    … and that method on fooFactory is implemented as ….

    public FooBase GetFoo() {
        return new FooSubtype();
    }
    

    Here, foo‘s type is FooBase (which may be an interface, abstract class, or unsealed concrete class), and (without casting) only its features are available. Clearly, FooSubtype implements or inherits from FooBase.

    The type that foo holds at runtime can be discerned here only because I show the implementation of GetFoo(), but it isn’t inspected by the compiler. In fact, the implementation may not even be available (could be in another assembly) or it may vary (could be virtual). For determining the compile-time type of GetFoo(), and therefore of foo, only the method declaration is relevant.

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

Sidebar

Related Questions

I've started reading Jon Skeet's early access version of his book, which contains sections
In his book High Performance Websites Steve Souders wrote (2007) that browsers limit parallel
In his book Java Design , Peter Coad says that one of the five
I am doing self-studying of operating systems. Tanenbaum in his book modern operating systems
In his book Effective Java , Joshua Bloch recommends against using Interfaces to hold
Andrew Troelsen in his book Pro C# 2008 and the .NET 3.5 Platform, Fourth
Meyers in his book 50 ways to improve... second edition writes that I must
Using Hadley's great ggplot2 and his book (pp. 78-79), I am able to produce
Itzik Ben-Gan explains in his book 'Inside Microsoft® SQL Server® 2008: T-SQL' how Appoach
Leonid wrote in chapter iv of his book : "... Module, Block and With.

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.