Tutorial by Examples: dc

When an object graph is finalized, the order is the reverse of the construction. E.g. the super-type is finalized before the base-type as the following code demonstrates: class TheBaseClass { ~TheBaseClass() { Console.WriteLine("Base class finalized!"); } } ...
public class SomeClass { public void DoStuff() { } protected void DoMagic() { } } public static class SomeClassExtensions { public static void DoStuffWrapper(this SomeClass someInstance) { someInstance.DoStuff(); // ok ...
The left-hand operand must be nullable, while the right-hand operand may or may not be. The result will be typed accordingly. Non-nullable int? a = null; int b = 3; var output = a ?? b; var type = output.GetType(); Console.WriteLine($"Output Type :{type}"); Console.WriteLine($&q...
String.Trim() string x = " Hello World! "; string y = x.Trim(); // "Hello World!" string q = "{(Hi!*"; string r = q.Trim( '(', '*', '{' ); // "Hi!" String.TrimStart() and String.TrimEnd() string q = "{(Hi*"; string r = q.TrimStart( '{...
At the command line, first verify that you have Git installed: On all operating systems: git --version On UNIX-like operating systems: which git If nothing is returned, or the command is not recognized, you may have to install Git on your system by downloading and running the installer. See...
Consider a database with the following two tables. Employees table: IdFNameLNameDeptId1JamesSmith32JohnJohnson4 Departments table: IdName1Sales2Marketing3Finance4IT Simple select statement * is the wildcard character used to select all available columns in a table. When used as a substitute f...
Using the def statement is the most common way to define a function in python. This statement is a so called single clause compound statement with the following syntax: def function_name(parameters): statement(s) function_name is known as the identifier of the function. Since a function def...
The math module contains the math.sqrt()-function that can compute the square root of any number (that can be converted to a float) and the result will always be a float: import math math.sqrt(9) # 3.0 math.sqrt(11.11) # 3.3331666624997918 math.sqrt(Decimal('6.25')) ...
break statement When a break statement executes inside a loop, control flow "breaks" out of the loop immediately: i = 0 while i < 7: print(i) if i == 4: print("Breaking from loop") break i += 1 The loop conditional will not be evaluated a...
Instead of this lambda-function that calls the method explicitly: alist = ['wolf', 'sheep', 'duck'] list(filter(lambda x: x.startswith('d'), alist)) # Keep only elements that start with 'd' # Output: ['duck'] one could use a operator-function that does the same: from operator import metho...
This a Basic example for using the MVVM model in a windows desktop application, using WPF and C#. The example code implements a simple "user info" dialog. The View The XAML <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> ...
The background-color property sets the background color of an element using a color value or through keywords, such as transparent, inherit or initial. transparent, specifies that the background color should be transparent. This is default. inherit, inherits this property from its parent e...
Signed integers can be of these types (the int after short, or long is optional): signed char c = 127; /* required to be 1 byte, see remarks for further information. */ signed short int si = 32767; /* required to be at least 16 bits. */ signed int i = 32767; /* required to be at least 16 bits */ ...
When it comes to adding/removing channels to/from your channel groups, you need to have must have the manage permission for those channel groups. But you should never grant clients the permission to manage the channel groups that they will subscribe to. If they did, then they could add any channel t...
Both the math and cmath-module contain the Euler number: e and using it with the builtin pow()-function or **-operator works mostly like math.exp(): import math math.e ** 2 # 7.3890560989306495 math.exp(2) # 7.38905609893065 import cmath cmath.e ** 2 # 7.3890560989306495 cmath.exp(2) # (...
Supposing you have a class that stores purely integer values: class Integer(object): def __init__(self, value): self.value = int(value) # Cast to an integer def __repr__(self): return '{cls}({val})'.format(cls=self.__class__.__name__, ...
ALTER TABLE Employees ADD StartingDate date NOT NULL DEFAULT GetDate(), DateOfBirth date NULL The above statement would add columns named StartingDate which cannot be NULL with default value as current date and DateOfBirth which can be NULL in Employees table.
Here's a standalone random number generator that doesn't rely on rand() or similar library functions. Why would you want such a thing? Maybe you don't trust your platform's builtin random number generator, or maybe you want a reproducible source of randomness independent of any particular library ...
Events fired on DOM elements don't just affect the element they're targeting. Any of the target's ancestors in the DOM may also have a chance to react to the event. Consider the following document: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> </hea...
Check whether a string is empty: if str.isEmpty { // do something if the string is empty } // If the string is empty, replace it with a fallback: let result = str.isEmpty ? "fallback string" : str Check whether two strings are equal (in the sense of Unicode canonical equivale...

Page 1 of 28