How to pass this by ref in C#?

The ref keyword causes Pass by Reference semantics – that is, if the variable is re-assigned in the called function, it will re-assign the variable in the caller as well. Obviously, this only works if a variable2 (which can be re-assigne to) is directly passed as the argument and will not work if an arbitrary … Read more

What does int.class mean

A primitive becoming an Object For primitives, there are Class objects available as constants named TYPE in the corresponding wrapper classes — i.e. int.class is changed to java.lang.Integer.TYPE . For other types, the compiler creates a private member variable in the class being compiled to hold the Class object, and generates code to initialize that … Read more

Rvalues, lvalues and formal definitions

Some preliminary paragraphs first: [basic] 3 An entity is a value, object, reference, function, enumerator, type, class member, template, template specialization, namespace, parameter pack, or this. [dcl.type.simple] 4 The type denoted by decltype(e) is defined as follows: if e is an unparenthesized id-expression or an unparenthesized class member access ([expr.ref]), decltype(e) is the type of … Read more

C++ strings: [] vs. *

Let’s look into it (for the following, note char const and const char are the same in C++): String literals and char * “hello” is an array of 6 const characters: char const[6]. As every array, it can convert implicitly to a pointer to its first element: char const * s = “hello”; For compatibility … Read more