Tutorial by Examples

The Master directive specifies a page file as being the mater page. The basic syntax of sample MasterPage directive is: <%@ MasterPage Language="C#" AutoEventWireup="true" CodeFile="SiteMater.master.cs" Inherits="SiteMaster" %>
The Import directive imports a namespace into a web page, user control page of application. If the Import directive is specified in the global.asax file, then it is applied to the entire application. If it is in a page of user control page, then it is applied to that page or control. The basic synt...
The MasterType directive assigns a class name to the Master property of a page, to make it strongly typed. The basic syntax of MasterType directive is: <%@ MasterType attribute="value"[attribute="value" ...] %>
The Page directive defines the attributes specific to the page file for the page parser and the compiler. The basic syntax of Page directive is: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Trace="tr...
The OutputCache directive controls the output caching policies of a web page or a user control. The basic syntax of OutputCache directive is: <%@ OutputCache Duration="15" VaryByParam="None" %>
This example show how you can check if a service already exists (i.e., is installed on the machine) or not. This code requires only the lowest privileges necessary, so each process can perform the check, no matter what level of security it is running at. #define UNICODE #define _UNICODE #include ...
>>> '{0:.0f}'.format(42.12345) '42' >>> '{0:.1f}'.format(42.12345) '42.1' >>> '{0:.3f}'.format(42.12345) '42.123' >>> '{0:.5f}'.format(42.12345) '42.12345' >>> '{0:.7f}'.format(42.12345) '42.1234500' Same hold for other way of referenc...
You can also use regular expressions to split a string. For example, import re data = re.split(r'\s+', 'James 94 Samantha 417 Scarlett 74') print( data ) # Output: ['James', '94', 'Samantha', '417', 'Scarlett', '74']
You can get rid of manage.py and use the django-admin command instead. To do so, you will have to manually do what manage.py does: Add your project path to your PYTHONPATH Set the DJANGO_SETTINGS_MODULE export PYTHONPATH="/home/me/path/to/your_project" export DJANGO_SETTINGS_MODULE...
IList<T> is never a subtype of a different IList<T1>. IList is invariant in its type parameter. class Animal { /* ... */ } class Dog : Animal { /* ... */ } IList<Dog> dogs = new List<Dog>(); IList<Animal> animals = dogs; // type error There is no subtype relat...
If you have a vsix file, you can install it by running the file. Get the vsix file (this is the extension installer) Run the file. In the window that opens, confirm the installation.
In Visual studio go to Tools > Extensions and updates... In the window that opens go to online Select Visual Studio Gallery You can search for an extension on the search box at the upper right corner Select the extension you want to add Click on download. Once download is complete, click...
int x = 5 / 0; // Undefined behavior Division by 0 is mathematically undefined, and as such it makes sense that this is undefined behavior. However: float x = 5.0f / 0.0f; // x is +infinity Most implementation implement IEEE-754, which defines floating point division by zero to return N...
int x = INT_MAX + 1; // x can be anything -> Undefined behavior If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined. (C++11 Standard paragraph 5/4) This is one of the mo...
To add annotations, hints, or exclude some code from being executed JavaScript provides two ways of commenting code lines Single line Comment // Everything after the // until the end of the line is excluded from execution. function elementAt( event ) { // Gets the element from Event coordinate...
By default, Django renders ForeignKey fields as a <select> input. This can cause pages to be load really slowly if you have thousands or tens of thousand entries in the referenced table. And even if you have only hundreds of entries, it is quite uncomfortable to look for a particular entry amo...
Using threading & queue: from socket import socket, AF_INET, SOCK_STREAM from threading import Thread from queue import Queue def echo_server(addr, nworkers): print('Echo server running at', addr) # Launch the client workers q = Queue() for n in range(nworkers): ...
Interfaces may have variant type parameters. interface IEnumerable<out T> { // ... } interface IComparer<in T> { // ... } but classes and structures may not class BadClass<in T1, out T2> // not allowed { } struct BadStruct<in T1, out T2> // not allo...
Record syntax can be used with newtype with the restriction that there is exactly one constructor with exactly one field. The benefit here is the automatic creation of a function to unwrap the newtype. These fields are often named starting with run for monads, get for monoids, and un for other typ...
Introduced in Java 8, default methods are a way of specifying an implementation inside an interface. This could be used to avoid the typical "Base" or "Abstract" class by providing a partial implementation of an interface, and restricting the subclasses hierarchy. Observer patte...

Page 279 of 1336