Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- namespace ImmutableList
- {
- public class ImmutableListMain
- {
- public static void Main()
- {
- Type immutableList = typeof(ImmutableList);
- FieldInfo[] fields = immutableList.GetFields();
- if (fields.Length < 1)
- {
- throw new Exception();
- }
- else
- {
- Console.WriteLine(fields.Length);
- }
- MethodInfo[] methods = immutableList.GetMethods();
- bool containsMethod = methods.Any(m => m.ReturnType.Name.Equals("ImmutableList"));
- if (!containsMethod)
- {
- throw new Exception();
- }
- else
- {
- Console.WriteLine(methods.Length);
- }
- }
- }
- public class ImmutableList
- {
- public List<int> integers;
- public ImmutableList(List<int> integers)
- {
- this.integers = integers;
- }
- public ImmutableList ReturnImmutableListCopy()
- {
- var copy = new List<int>();
- foreach (var item in this.integers)
- {
- copy.Add(item);
- }
- return new ImmutableList(copy);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement