コード例 #1
0
        public float this[int row, int col]
        {
            get
            {
                ThrowIfOutOfRange(row, col, this.Width, this.Height);
                RowColKey key = new RowColKey(row, col);
                if (this._elements.ContainsKey(key))
                {
                    return(this._elements[key]);
                }
                else
                {
                    return(0);
                }
            }

            set
            {
                ThrowIfOutOfRange(row, col, this.Width, this.Height);
                RowColKey key = new RowColKey(row, col);
                if (this._elements.ContainsKey(key))
                {
                    this._elements[key] = value;
                }
                else
                {
                    this._elements.Add(key, value);
                }
            }
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            if (System.Object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            RowColKey key = obj as RowColKey;

            if (key == null)
            {
                return(false);
            }

            return((this.Row == key.Row) && (this.Col == key.Col));
        }