Tutorial by Examples: c

List subList(int fromIndex, int toIndex) Here fromIndex is inclusive and toIndex is exclusive. List list = new ArrayList(); List list1 = list.subList(fromIndex,toIndex); If the list doesn't exist in the give range, it throws IndexOutofBoundException. What ever changes made on the list1 wi...
Often you want to match an expression only in specific places (leaving them untouched in others, that is). Consider the following sentence: An apple a day keeps the doctor away (I eat an apple everyday). Here the "apple" occurs twice which can be solved with so called backtracking cont...
The result of a reinterpret_cast from one function pointer type to another, or one function reference type to another, is unspecified. Example: int f(); auto fp = reinterpret_cast<int(*)(int)>(&f); // fp has unspecified value C++03 The result of a reinterpret_cast from one object poi...
Custom validation attributes can be created by deriving from the ValidationAttribute base class, then overriding virtual methods as needed. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public class NotABananaAttribute : ValidationAttribute { public ov...
Introduces a case label of a switch statement. The operand must be a constant expression and match the switch condition in type. When the switch statement is executed, it will jump to the case label with operand equal to the condition, if any. char c = getchar(); bool confirmed; switch (c) { c...
According to the C++ standard, The switch statement causes control to be transferred to one of several statements depending on the value of a condition. The keyword switch is followed by a parenthesized condition and a block, which may contain case labels and an optional default label. When t...
The catch keyword introduces an exception handler, that is, a block into which control will be transferred when an exception of compatible type is thrown. The catch keyword is followed by a parenthesized exception declaration, which is similar in form to a function parameter declaration: the paramet...
An integer type which is "large enough to store any member of the implementation’s basic character set". It is implementation-defined whether char is signed (and has a range of at least -127 to +127, inclusive) or unsigned (and has a range of at least 0 to 255, inclusive). const char zer...
Less doesn't put any restrictions on the number of times the parent selector (&) can be used in a complex selector and so, we can use it more than once like in the below examples to select sibling elements without the need to repeat the selector. .demo { border: 1px solid black; /* add borde...
The following snippet replaces all Attributes called PreviousAttribute by an Attribute called ReplacementAttribute for an entire solution. The sample manually searches the Syntax tree and replaces all affected nodes. static async Task<bool> ModifySolution(string solutionPath) { ...
The following snippet replaces all Attributes called "PreviousAttribute" by an Attribute called "ReplacementAttribute" for an entire solution. The sample manually uses a SyntaxRewriter to exchange the attributes. /// <summary> /// The CSharpSyntaxRewriter allows to rewrit...
C11 The function specifier _Noreturn was introduced in C11. The header <stdnoreturn.h> provides a macro noreturn which expands to _Noreturn. So using _Noreturn or noreturn from <stdnoreturn.h> is fine and equivalent. A function that's declared with _Noreturn (or noreturn) is not allowe...
Sometimes a poorly designed 3rd-party library will write unwanted diagnostics to System.out or System.err streams. The recommended solutions to this would be to either find a better library or (in the case of open source) fix the problem and contribute a patch to the developers. If the above solu...
Function calls as f(a) always imply a sequence point between the evaluation of the arguments and the designator (here f and a) and the actual call. If two such calls are unsequenced, the two function calls are indeterminately sequenced, that is, one is executed before the other, and order is unspeci...
C++11 An unsigned integer type with the same size and alignment as uint_least16_t, which is therefore large enough to hold a UTF-16 code unit. const char16_t message[] = u"你好,世界\n"; // Chinese for "hello, world\n" std::cout << sizeof(message)/sizeof(char16_t) ...
C++11 An unsigned integer type with the same size and alignment as uint_least32_t, which is therefore large enough to hold a UTF-32 code unit. const char32_t full_house[] = U"🂣🂳🂨🂸🃈"; // non-BMP characters std::cout << sizeof(full_house)/sizeof(char32_t) <<...
Introduces the definition of a class type. class foo { int x; public: int get_x(); void set_x(int new_x); }; Introduces an elaborated type specifier, which specifies that the following name is the name of a class type. If the class name has been declared already, it ca...
Interchangeable with class, except for the following differences: If a class type is defined using the keyword struct, then the default accessibility of bases and members is public rather than private. struct cannot be used to declare a template type parameter or template template parameter; onl...
Most PRAGMA statements affect only the current database connection, which means that they have to be re-applied whenever the database has been opened. However, the following PRAGMAs write to the database file, and can be executed at any time (but in some cases, not inside a transaction): applica...
A type specifier; when applied to a type, produces the const-qualified version of the type. See const keyword for details on the meaning of const. const int x = 123; x = 456; // error int& r = x; // error struct S { void f(); void g() const; }; const S s; s.f(); // error s...

Page 446 of 826