Tutorial by Examples: and

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...
In Haskell, data types can have arguments just like functions. Take the Maybe type for example. Maybe is a very useful type which allows us to represent the idea of failure, or the possiblity thereof. In other words, if there is a possibility that a computation will fail, we use the Maybe type ther...
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...
Layout Unity basic editor will look like below. Basic functionalities of some default windows/tabs are described in the image. Linux Layout There is a little difference in menu layout of linux version, like the screenshot below, Basic Usage Create an empty GameObject by right clicking in th...
Whenever a Python script is invoked from the command line, the user may supply additional command line arguments which will be passed on to the script. These arguments will be available to the programmer from the system variable sys.argv ("argv" is a traditional name used in most programmi...
If you are able to download an update of Android Studio, but after it restarts nothing happens, check out the following example: After the patch was downloaded and Android Studio closed, open the terminal Go to your android studio folder, e.g. cd ~/android-studio Go to bin subfolder: cd bin ...
To use Leaflet, load its stylesheet and JavaScript file to your page: <link rel="stylesheet" href="/css/leaflet.css" /> <script src="/js/leaflet.js"></script> These resources can be downloaded from a variety of locations such as Leaflet's homepage...
It is usually not a good idea to mix signed and unsigned integers in arithmetic operations. For example, what will be output of following example? #include <stdio.h> int main(void) { unsigned int a = 1000; signed int b = -1; if (a > b) puts("a is more than b&quot...
The simplest way to concatenate list1 and list2: merged = list1 + list2 zip returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables: alist = ['a1', 'a2', 'a3'] blist = ['b1', 'b2', 'b3'] for a, b in zip(alist, blist):...
Installation npm install -D webpack typescript ts-loader webpack.config.js module.exports = { entry: { app: ['./src/'], }, output: { path: __dirname, filename: './dist/[name].js', }, resolve: { extensions: ['', '.js', '.ts'], }, module: { loaders: [...
To retrieve a list of all servers registered on the instance: EXEC sp_helpserver;
A java.util.Date object does not have a concept of time zone. There is no way to set a timezone for a Date There is no way to change the timezone of a Date object A Date object created with the new Date() default constructor will be initialised with the current time in the system default timezo...
A hexadecimal number is a value in base-16. There are 16 digits, 0-9 and the letters A-F (case does not matter). A-F represent 10-16. An octal number is a value in base-8, and uses the digits 0-7. A binary number is a value in base-2, and uses the digits 0 and 1. All of these numbers result in ...
import flash.net.URLRequest; import flash.media.Sound; import flash.events.Event; var req:URLRequest = new URLRequest("click.mp3"); var snd:Sound = new Sound(req); snd.addEventListener(Event.COMPLETE, function(e: Event) { snd.play(); }
package { import flash.events.EventDispatcher; public class AbstractDispatcher extends EventDispatcher { public function AbstractDispatcher(target:IEventDispatcher = null) { super(target); } } } To dispatch an event on an instance: var dispatcher:AbstractDispatcher =...
There are situations when you need to calculate something really large in your Flash application, while not interrupting the user's experience. For this, you need to devise your lengthy process as a multi-step process with saved state between iterations. For example, you need to perform a background...
Installation The preferred way to install Mockito is to declare a dependency on mockito-core with a build system of choice. As of July 22nd, 2016, the latest non-beta version is 1.10.19, but 2.x is already encouraged to be migrated to. Maven <dependency> <groupId>org.mockito</...

Page 28 of 153