Tutorial by Examples

An event allows the developer to implement a notification pattern. Simple example public class Server { // defines the event public event EventHandler DataChangeEvent; void RaiseEvent() { var ev = DataChangeEvent; if(ev != null) { ev(t...
Building project dependencies can sometimes be a tedious task. Instead of publishing a package version to NPM and installing the dependency to test the changes, use npm link. npm link creates a symlink so the latest code can be tested in a local environment. This makes testing global tools and proje...
To locate comments in BeautifulSoup, use the text (or string in the recent versions) argument checking the type to be Comment: from bs4 import BeautifulSoup from bs4 import Comment data = """ <html> <body> <div> <!-- desired text --&gt...
The %timeit magic runs the given code many times, then returns the speed of the fastest result. In [1]: %timeit sum(range(100000)) 100 loops, best of 3: 2.91 ms per loop The %%timeit cell magic can be used to time blocks of code. In [2]: %%timeit ...: a = 0 ...: for i in range(100000):...
R provides two additional looping constructs, while and repeat, which are typically used in situations where the number of iterations required is indeterminate. The while loop The general form of a while loop is as follows, while (condition) { ## do something ## in loop body } whe...
First, let's see three different ways of extracting data from a file. string fileText = File.ReadAllText(file); string[] fileLines = File.ReadAllLines(file); byte[] fileBytes = File.ReadAllBytes(file); On the first line, we read all the data in the file as a string. On the second line, we r...
Iterating over connected serial ports using System.IO.Ports; string[] ports = SerialPort.GetPortNames(); for (int i = 0; i < ports.Length; i++) { Console.WriteLine(ports[i]); } Instantiating a System.IO.SerialPort object using System.IO.Ports; SerialPort port = new SerialPort(); ...
This example is about replacing a List element while ensuring that the replacement element is at the same position as the element that is replaced. This can be done using these methods: set(int index, T type) int indexOf(T type) Consider an ArrayList containing the elements "Program sta...
A conversion that involves calling an explicit constructor or conversion function can't be done implicitly. We can request that the conversion be done explicitly using static_cast. The meaning is the same as that of a direct initialization, except that the result is a temporary. class C { std:...
static_cast can perform any implicit conversion. This use of static_cast can occasionally be useful, such as in the following examples: When passing arguments to an ellipsis, the "expected" argument type is not statically known, so no implicit conversion will occur. const double x = ...
For a class Person like: public class Person { public string Name { get; set; } public int Age { get; set; } public string Clothes { get; set; } } var person1 = new Person { Name = "Jon", Age = 20, Clothes = "some clothes" }; var person2 = new Person { Name ...
For given type Person: public class Person { public string Name { get; set; } public int Age { get; set; } public string Clothes { get; set; } } List<Person> persons = new List<Person> { new Person{ Name = "Jon", Age = 20, Clothes = "some clothes...
There are two basic classes of exact numeric data types - Integer, and Fixed Precision and Scale. Integer Data Types bit tinyint smallint int bigint Integers are numeric values that never contain a fractional portion, and always use a fixed amount of storage. The range and storage sizes o...
float [(n)] real These data types are used to store floating point numbers. Since these types are intended to hold approximate numeric values only, these should not be used in cases where any rounding error is unacceptable. However, if you need to handle very large numbers, or numbers with an ...
These types are in all versions of SQL Server datetime smalldatetime These types are in all versions of SQL Server after SQL Server 2012 date datetimeoffset datetime2 time
binary varbinary image
cursor timestamp hierarchyid uniqueidentifier sql_variant xml table Spatial Types
This example shows how to render text along an arc. It includes how you can add functionality to the CanvasRenderingContext2D by extending its prototype. This examples is derived from the stackoverflow answer Circular Text. Example rendering Example code The example adds 3 new text renderi...

Page 731 of 1336