Tech Off Post

Single Post Permalink

View Thread: LINQ Question
  • User profile image

    SecretSoftware wrote:
    Error    2    Property or indexer 'AnonymousType#1.MyAnnoymousP' cannot be assigned to -- it is read only  

    Why did this became like this as we go from Beta 1 to Beta 2?

    This code generated the above error

    var q = from x in y
                 where x.d = 1
                 select new {MyAnnoymousP = x.L, x.J};

    q.MyAnnoymousP = Something;

    in beta 1 this was valid, but in Beta 2 it became ReadOnly. Why? Will this change? Is this a bug in Beta 2?


    littleguru gave a good answer, but I'd like to point out that your code above has several bugs and won't even compile.  I realize this is example code typed on the fly, so I'm not trying to be a "code cop", but until I read the answer from littleguru I couldn't even figure out what you thought was wrong. [C]