Created
June 10, 2017 15:40
-
-
Save musoftware/464a8714a63ccfa3fb97eb17faadd6c3 to your computer and use it in GitHub Desktop.
ReadOnly ReAssign
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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