Richard Creamer

My feedback

  1. 221 votes
    Sign in
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      You have left! (?) (thinking…)
      13 comments  ·  Visual Studio IDE » Languages - C#  ·  Flag idea as inappropriate…  ·  Admin →
      Richard Creamer commented  · 

      I agree with the suggester. The 'const' keyword does not allow a local variable to be assigned a non-constant value (e.g. an expression such as DateTime.Now.Millisecond) and I agree that these semantics are appropriate for 'const'.

      Since 'const' cannot fill this role, extending 'readonly' to fill this role would be helpful.

      For example, the 'final' keyword in Java allows a developer to declare that a variable (method parameter, local variable, instance variable) will immutable after assignment. This is a nice way to ensure a future developer doesn't inadvertently change its value and would probably come in handy in a multithreaded execution environment.

      I think it would be a nice addition to C#.

    Feedback and Knowledge Base