Tutorial by Examples: er

Generate a random number between 0 and 1.0. (not including 1.0) Random rnd = new Random(); var randomDouble = rnd.NextDouble();
Generate a random number between minValue and maxValue - 1. Random rnd = new Random(); var randomBetween10And20 = rnd.Next(10, 20);
When creating Random instances with the same seed, the same numbers will be generated. int seed = 5; for (int i = 0; i < 2; i++) { Console.WriteLine("Random instance " + i); Random rnd = new Random(seed); for (int j = 0; j < 5; j++) { Console.Write(rnd.Next(...
Two Random class created at the same time will have the same seed value. Using System.Guid.NewGuid().GetHashCode() can get a different seed even in the same time. Random rnd1 = new Random(); Random rnd2 = new Random(); Console.WriteLine("First 5 random number in rnd1"); for (int i = 0...
There are three visibility types that you can apply to methods (class/object functions) and properties (class/object variables) within a class, which provide access control for the method or property to which they are applied. You can read extensively about these in the PHP Documentation for OOP Vi...
Include a row number according to the order specified. SELECT ROW_NUMBER() OVER(ORDER BY Fname ASC) AS RowNumber, Fname, LName FROM Employees
Uses a partition criteria to group the row numbering according to it. SELECT ROW_NUMBER() OVER(PARTITION BY DepartmentId ORDER BY DepartmentId ASC) AS RowNumber, DepartmentId, Fname, LName FROM Employees
This query selects all employees not on the Supervisors table. SELECT * FROM Employees WHERE EmployeeID not in (SELECT EmployeeID FROM Supervisors) The same results can be achieved using a LEFT JOIN. SELECT * FROM Employees AS e LEFT JOIN Supervisors AS s ON s.E...
Definition : When multiple methods with the same name are declared with different parameters, it is referred to as method overloading. Method overloading typically represents functions that are identical in their purpose but are written to accept different data types as their parameters. Factors af...
We can match on lists like any other data type, though they are somewhat unique, in that the constructor for building up lists is the infix function ::. (See the example Creating a list for more on how that works.) matchMyList : List SomeType -> SomeOtherType matchMyList myList = case myL...
If you're ever dealing with C Binary API's from Perl Code, via the syscall, ioctl, or fcntl functions, you need to know how to construct memory in a C Compatible way. For instance, if you were ever dealing with some function that expected a timespec, you'd look into /usr/include/time.h and find: s...
The procedure describes how to add an Object library reference, and afterwards how to declare new variables with reference to the new library class objects. The example below shows how to add the PowerPoint library to the existing VB Project. As can be seen, currently the PowerPoint Object library...
String literals imply no escaping or interpolation ( with the exception of quoting string terminators ) print 'This is a string literal\n'; # emits a literal \ and n to terminal print 'This literal contains a \'postraphe '; # emits the ' but not its preceding \ You can use alternative quoting...
Large Multi-Line strings are burdensome to write. my $variable = <<'EOF'; this block of text is interpreted literally, no \'quotes matter, they're just text only the trailing left-aligned EOF matters. EOF NB: Make sure you ignore stack-overflows syntax highlighter: It is very wrong. A...
import pandas as pd import numpy as np np.random.seed(0) rng = pd.date_range('2015-02-24', periods=5, freq='T') s = pd.Series(np.random.randn(len(rng)), index=rng) print (s) 2015-02-24 00:00:00 1.764052 2015-02-24 00:01:00 0.400157 2015-02-24 00:02:00 0.978738 2015-02-24 00:0...
To support a given application, you often create a new role and database to match. The shell commands to run would be these: $ createuser -P blogger Enter password for the new role: ******** Enter it again: ******** $ createdb -O blogger blogger This assumes that pg_hba.conf has been prope...
Introduction The BufferedReader class is a wrapper for other Reader classes that serves two main purposes: A BufferedReader provides buffering for the wrapped Reader. This allows an application to read characters one at a time without undue I/O overheads. A BufferedReader provides functi...
If we know the length of the string, we can use a for loop to iterate over its characters: char * string = "hello world"; /* This 11 chars long, excluding the 0-terminator. */ size_t i = 0; for (; i < 11; i++) { printf("%c\n", string[i]); /* Print each character of ...
Occasionally you'd want to catch an exception and throw it from a different thread or method while preserving the original exception stack. This can be done with ExceptionDispatchInfo: using System.Runtime.ExceptionServices; void Main() { ExceptionDispatchInfo capturedException = null; ...
Due to logical query processing order, alias can be used in order by. SELECT DisplayName, JoinDate as jd, Reputation as rep FROM Users ORDER BY jd, rep And can use relative order of the columns in the select statement .Consider the same example as above and instead of using alias use the relat...

Page 78 of 417