text: MS Dynamics CRM 3.0
  I have just started learning C# ; I was working in C++ till now (and would like to if allowed, but learning new things dont hurt). I am used to specifiying "const" to get the assurance that unless someone specifically cast-away the constness, object wont change. So, as part of my first ever program I wrote a following class -
  public class FirstOne { public int intTry; public FirstOne() { intTry = 0; }
  //public FirstOne(readonly FirstOne o) //public FirstOne(const FirstOne o) public FirstOne(FirstOne o) { intTry = o.intTry; o.intTry = -100; // This would be possible if I can't make the parameter const..
  } }
  Since class in C# is reference type (still getting hang of the concept) object 'o' is already a reference, I am just trying to make it const so that it doesn't change. But the syntax (commented lines) does not work. Is it even possible to have const ref or it's just a glitch in my C# syntax understanding?
  Thanks in advance, Neel.
  You could perhaps make the class immutable, but this prevents anybody from changing the contents (you need to recreate the object from scratch to "change" it). You could create an interface with only the "get" accessors, but that doesn't prevent you from casting back to the real type.
  Otherwise you could perhaps pass clones around, but that is an overhead and relies on the various parties playing ball. There is no C# syntax to do what you want (treat a mutable object as immutable within a scope).
  Marc -----------------------------------------------Reply-----------------------------------------------
  public readonly int intTry;
  now *only* the constructor can set intTry.
  Also - can I recommend using properties instead of direct fields? In simple cases this will be inlined by the JIT anyway, but gives you a lot more flexibility to add functionality; as an example (with a use-case)...
  private void CheckEditable() { // allow some kind of lock/unlock mechanism... if(!IsEditable) throw new InvalidOperationException("The record is not currently editable");
  - Hide quoted text -
  Even if I have just started learning it now, I can't help but wonder why it was left out..
  Thanks, Neel.