Skip to content

Instantly share code, notes, and snippets.

@musoftware
Created June 10, 2017 15:40
Show Gist options
  • Save musoftware/464a8714a63ccfa3fb97eb17faadd6c3 to your computer and use it in GitHub Desktop.
Save musoftware/464a8714a63ccfa3fb97eb17faadd6c3 to your computer and use it in GitHub Desktop.
ReadOnly ReAssign
using System;
class Program
{
class _class
{
public readonly int readOnly = 1;
public _class() { }
public _class(int newValue)
{
readOnly = newValue;
}
}
static void Main(string[] args)
{
_class c1 = new _class();
_class c2 = new _class(5);
Console.WriteLine("Orginal: " + c1.readOnly);
Console.WriteLine("New Value: " + c2.readOnly);
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment