public   T this[PairItem index] {
                get {
                    switch (index)
                    {
                    case PairItem.First:
                        return(First);

                    case PairItem.Second:
                        return(Second);

                    default:
                        throw new NotImplementedException($"The enum {index.ToString()} has not been implemented");
                    }
                }
            }
        }                        // C# 6.0 Getter-Only Autoproperty

        public T this[PairItem index]
        {
            get
            {
                switch (index)
                {
                case PairItem.First:
                    return(First);

                case PairItem.Second:
                    return(Second);

                default:
                    throw new NotImplementedException(
                              string.Format(
                                  "The enum {0} has not been implemented",
                                  index.ToString()));
                }
            }

            /*
             * // In keeping with the principal that structs should
             * // be read-only, the setter is commented out
             *
             * set
             * {
             *  switch(index)
             *  {
             *      case PairItem.First:
             *          First = value;
             *          break;
             *      case PairItem.Second:
             *          Second = value;
             *          break;
             *      default:
             *          throw new NotImplementedException(
             *              string.Format(
             *              "The enum {0} has not been implemented",
             *              index.ToString()));
             *  }
             * }
             */
        }
Exemple #3
0
        public T this[PairItem index]
        {
            get
            {
                switch (index)
                {
                case PairItem.First:
                    return(First);

                case PairItem.Second:
                    return(Second);

                default:
                    throw new NotImplementedException(
                              string.Format(
                                  "The enum {0} has not been implemented",
                                  index.ToString()));
                }
            }
            #endregion Indexer
        }
 public T this[PairItem index]
 {
     get
     {
         PairItem pairItem  = index;
         PairItem pairItem2 = pairItem;
         T        result;
         if (pairItem2 != PairItem.First)
         {
             if (pairItem2 != PairItem.Second)
             {
                 throw new NotImplementedException(string.Format("The enum {0} has not been implemented", index.ToString()));
             }
             result = Second;
         }
         else
         {
             result = First;
         }
         return(result);
     }
 }