Last active
January 7, 2022 23:59
-
-
Save kolosovpetro/e76f1c288b6da674fe4965045a2585f0 to your computer and use it in GitHub Desktop.
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; | |
| namespace CoinChangeProblem.UI | |
| { | |
| public static class Program | |
| { | |
| public static void Main() | |
| { | |
| var user = new User("initial_name"); | |
| user.SetName("test_1"); | |
| user.SetName("test_2"); | |
| user.SetName("test_3"); | |
| user.SetName("test_4"); | |
| user.SetName("test_5"); | |
| Console.WriteLine(user.Name); | |
| } | |
| } | |
| public struct User | |
| { | |
| public string Name { get; set; } | |
| public User(string name) | |
| { | |
| Name = name; | |
| } | |
| public readonly void SetName(string name) | |
| { | |
| ChangeName(name); | |
| } | |
| private void ChangeName(string newName) | |
| { | |
| Name = newName; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment