Created
June 8, 2019 03:59
-
-
Save DamianSuess/a61125315a1e8b3a73940c2a2c882212 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
public static class ListExtension | |
{ | |
public static void Add<T>(this List<T> list, T value, out List<T> newInstance) | |
{ | |
if (list == null) list = new List<T>(); | |
list?.Add(value); | |
newInstance = list; | |
} | |
} | |
[Test] | |
public void ListAddTest() | |
{ | |
List<string> list = null; | |
list.Add("test",out list); | |
Assert.AreEqual(1,list.Count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment