[.net] Strange C# rule?

Started by
3 comments, last by Daniel Miller 18 years, 9 months ago
This code gives me "The left-hand side of an assignment must be a variable, property or indexer"
for (int i = 0; i < list.Count; ++i)
{
	((Type)list).publicField *= 2;
}
What am I missing here?
Advertisement
Hmmm. Is (Type) really the type you're casting... meaning is this the exact code? If it is, there is no publicField property or member in the System.Type class to assign the value to. This could be your problem. Otherwise, if you have created a class that they Type represents and the publicField is really a public field, there might be another issue.
you need to post the real code.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Well, that was simplification of what was going on, and when I wrote up that program it compiled. [sad]

I'll go see what is wrong here...
It's a struct, not a class. Why didn't I notice that??

Thanks for the replies, though. [smile]

This topic is closed to new replies.

Advertisement