Tutorial by Examples

Caller info attributes can be used to pass down information about the invoker to the invoked method. The declaration looks like this: using System.Runtime.CompilerServices; public void LogException(Exception ex, [CallerMemberName]string callerMemberName = "", ...
Optional Parameters In TypeScript, every parameter is assumed to be required by the function. You can add a ? at the end of a parameter name to set it as optional. For example, the lastName parameter of this function is optional: function buildName(firstName: string, lastName?: string) { // ...
Returns one of two values depending on the value of a Boolean expression. Syntax: condition ? expression_if_true : expression_if_false; Example: string name = "Frank"; Console.WriteLine(name == "Frank" ? "The name is Frank" : "The name is not Frank"); ...
Boolean(...) will convert any data type into either true or false. Boolean("true") === true Boolean("false") === true Boolean(-1) === true Boolean(1) === true Boolean(0) === false Boolean("") === false Boolean("1") === true Boolean("0") === t...
In themes.xml: <style name="AppTheme" parent="Theme.AppCompat"> <!-- Theme attributes here --> </style> In AndroidManifest.xml: <application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" andr...
You can customize your theme’s color palette. Using framework APIs 5.0 <style name="AppTheme" parent="Theme.Material"> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/pri...
In themes.xml: <style name="MyActivityTheme" parent="Theme.AppCompat"> <!-- Theme attributes here --> </style> In AndroidManifest.xml: <application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" ...
Have required JavaScript and CSS files included in your index.html. You can do this by either using the CDN files availiable at the following paths: <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css"> <scr...
XML elements often nest, have data in attributes and/or as character data. The way to capture this data is by using ,attr and ,chardata respectively for those cases. var doc = ` <parent> <child1 attr1="attribute one"/> <child2>and some cdata</child2> </p...
Here is a simple Python command-line program which will connect to a Twitch channel as a bot and respond to a few simple commands. Dependencies: irc Python lib (pip install irc or easy_install irc) Source: https://gist.github.com/jessewebb/65b554b5be784dd7c8d1 import logging import sys f...
Pointer Methods Pointer methods can be called even if the variable is itself not a pointer. According to the Go Spec, . . . a reference to a non-interface method with a pointer receiver using an addressable value will automatically take the address of that value: t.Mp is equivalent to (&t)....
Channels are often used to implement timeouts. func main() { // Create a buffered channel to prevent a goroutine leak. The buffer // ensures that the goroutine below can eventually terminate, even if // the timeout is met. Without the buffer, the send on the channel // blocks fo...
The primary task of the manifest is to inform the system about the app's components. For example, a manifest file can declare an activity as follows: <?xml version="1.0" encoding="utf-8"?> <manifest ... > <application android:icon="@drawable/app_icon.pn...
Using the Android API 23 or higher, very often such situation can be seen: This situation is caused by the structural change of the Android API regarding getting the resources. Now the function: public int getColor(@ColorRes int id, @Nullable Theme theme) throws NotFoundException should ...
You can mix normal parameters and parameter arrays: public class LotteryTicket : IEnumerable{ public int[] LuckyNumbers; public string UserName; public void Add(string userName, params int[] luckyNumbers){ UserName = userName; Lottery = luckyNumbers; } } ...
package main import ( "log" "sync" "time" ) func main() { // The WaitGroup lets the main goroutine wait for all other goroutines // to terminate. However, this is no implicit in Go. The WaitGroup must // be explicitely incremented pr...
package main import ( "fmt" "time" ) // The pinger prints a ping and waits for a pong func pinger(pinger <-chan int, ponger chan<- int) { for { <-pinger fmt.Println("ping") time.Sleep(time.Second) ponge...
/** * Created by Alex Sullivan on 7/21/16. */ public class Foo implements Parcelable { private final int myFirstVariable; private final String mySecondVariable; private final long myThirdVariable; public Foo(int myFirstVariable, String mySecondVariable, long myThirdVariab...
This tutorial explains how to download Image using AsyncTask in Android. The example below download image while showing progress bar while during download. Understanding Android AsyncTask Async task enables you to implement MultiThreading without get Hands dirty into threads. AsyncTask enables pro...
Operators such as +, -, ?? are a kind of function named using symbols rather than letters. They are invoked differently from functions: Prefix: -x Infix: x + y Postfix: x++ You can read more about basic operators and advanced operators in The Swift Programming Language.

Page 227 of 1336