Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<MyClass> list = new List<MyClass>();
- void Main()
- {
- for (int i = 0; i < 8; i++)
- {
- Add();
- }
- list.Dump();
- }
- void Add()
- {
- if (list.Count == 0)
- {
- list.Add(new MyClass(1));
- return;
- }
- var last = list.Last().Value;
- list.Add(new MyClass(last < 4 ? last + 1 : -last + 1));
- }
- class MyClass
- {
- public int Value {get; private set;}
- public MyClass(int value)
- {
- Value = value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement