You should be aware that a couple of language constructs have a different terminology in C# from that in C++. Member variables in C++ are known as fields in C#, and functions in C++ are known as methods in C#. In C#, the term function has a more general meaning and refers to any member of a class that contains code. This means that "function" covers methods, properties, constructors, destructors, indexers, and operator overloads. In C++, "function" and "method" are often used interchangeably in casual speech, though strictly a C++ method is a virtual member function.
If this all sounds confusing, the following table should help.
Meaning | C++ Term | C# Term |
---|---|---|
Variable that is a member of a class | Member variable | Field |
Any item in a class that contains instructions | Function (or member function) | Function |
Item in a class that contains instructions and is callable by name with the syntax DoSomething(/*parameters*/). | Function (or member function) | Method |
Virtual function that is defined as a member of a class | Method | Virtual method |
You should also be aware of the differences in terminology listed in the following table.
C++ Term | C# Term |
---|---|
Compound statement | Block statement |
Lvalue | Variable expression |
This appendix, where possible, uses the terminology appropriate to the language being discussed.