13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATIONusing System;class Grid{const int NumRows = 26;const int NumCols = 10;int[,] cells = new int[NumRows, NumCols];}end example]public int this[char c, int colm]{get {c = Char.ToUpper(c);if (c < 'A' || c > 'Z') {throw new ArgumentException();}if (colm < 0 || colm >= NumCols) {throw new IndexOutOfRangeException();}return cells[c - 'A', colm];}set {c = Char.ToUpper(c);if (c < 'A' || c > 'Z') {throw new ArgumentException();}if (colm < 0 || colm >= NumCols) {throw new IndexOutOfRangeException();}cells[c - 'A', colm] = value;}}17.8.1 Indexer overloadingThe indexer overload resolution rules are described in §14.4.2.17.9 OperatorsAn operator is a member that defines the meaning of an expression operator that can be applied to instances ofthe class. Operators are declared using operator-declarations:operator-declaration:attributes opt operator-modifiers operator-declarator operator-bodyoperator-modifiers:operator-modifieroperator-modifiers operator-modifieroperator-modifier:publicstaticexternoperator-declarator:unary-operator-declaratorbinary-operator-declaratorconversion-operator-declaratorunary-operator-declarator:type operator overloadable-unary-operator ( type identifier )overloadable-unary-operator: one of+ - ! ~ ++ -- true false254

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!