public PlayFair(PlayFairSettings settings, string key) { Settings = settings; Key = key; // Формирование матрицы _positions = new Dictionary <char, TablePosition>(); var items = MatrixItems().GetEnumerator(); _matrix = new char[settings.Rows, settings.Columns]; for (var r = 0; r < settings.Rows; r++) { for (var c = 0; c < settings.Columns; c++) { if (items.MoveNext()) { _matrix[r, c] = items.Current; _positions.Add(items.Current, new TablePosition(r, c)); } else { throw new ArgumentException("Алфавит слишком маленький"); } } } }
private Dictionary<char, TablePosition> Positions; // Позиции символов в матрице #endregion Fields #region Constructors public PlayFair(PlayFairSettings Settings, string Key) { this.Settings = Settings; this.Key = Key; // Формирование матрицы Positions = new Dictionary<char, TablePosition>(); var items = MatrixItems().GetEnumerator(); Matrix = new char[Settings.Rows, Settings.Columns]; for (var r = 0; r < Settings.Rows; r++) { for (var c = 0; c < Settings.Columns; c++) { if (items.MoveNext()) { Matrix[r, c] = items.Current; Positions.Add(items.Current, new TablePosition(r, c)); } else throw new ArgumentException("Алфавит слишком маленький"); } } }