Advertisement
Guest User

Untitled

a guest
Jan 8th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApplication1
  5. {
  6.     public class Program
  7.     {
  8.         public static void Main()
  9.         {
  10.             Outer.Nested.CreateInstance(34);
  11.             Outer.Nested.CreateInstance(5);
  12.             Outer.Nested.CreateInstance(21);
  13.             Console.WriteLine(Outer.Nested.CompareRecord(0, 34));
  14.         }
  15.     }
  16.  
  17.     public class Outer
  18.     {
  19.         private readonly int _field;
  20.  
  21.         public Outer(int field)
  22.         {
  23.             _field = field;
  24.         }
  25.  
  26.         public static class Nested
  27.         {
  28.             private static readonly List<Outer> ListOfNested = new List<Outer>();
  29.  
  30.             public static void CreateInstance(int input)
  31.             {
  32.                 Outer record = new Outer(input);
  33.                 ListOfNested.Add(record);
  34.             }
  35.  
  36.             public static bool CompareRecord(int location, int num)
  37.                 => ListOfNested[location]._field == num;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement