Created
May 23, 2022 12:40
-
-
Save lgolubyev/ee235ff6ff435892516f574f9deed665 to your computer and use it in GitHub Desktop.
This file contains 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
MyClass myClass = new MyClass(); | |
((List<string>)myClass.ReadOnlyNameCollection).Add("######From Client#####"); | |
myClass.Print(); | |
} | |
} | |
class MyClass | |
{ | |
List<string> _nameCollection = new List<string>(); | |
public MyClass() | |
{ | |
_nameCollection.Add("Rob"); | |
_nameCollection.Add("John"); | |
_nameCollection.Add("Jummy"); | |
_nameCollection.Add("Derek"); | |
} | |
public IEnumerable<string> ReadOnlyNameCollection | |
{ | |
get { return _nameCollection.AsEnumerable(); } | |
} | |
public void Print() | |
{ | |
foreach (var item in ReadOnlyNameCollection) | |
{ | |
Console.WriteLine(item); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment