Tutorial by Examples: cli

string requestUri = "http://www.example.com"; string responseData; using (var client = new WebClient()) { responseData = client.DownloadString(requestUri); }
HttpClient is available through NuGet: Microsoft HTTP Client Libraries. string requestUri = "http://www.example.com"; string responseData; using (var client = new HttpClient()) { using(var response = client.GetAsync(requestUri).Result) { response.EnsureSuccessStatus...
string requestUri = "http://www.example.com"; string requestBodyString = "Request body string."; string contentType = "text/plain"; string requestMethod = "POST"; byte[] responseBody; byte[] requestBodyBytes = Encoding.UTF8.GetBytes(requestBodyS...
HttpClient is available through NuGet: Microsoft HTTP Client Libraries. string requestUri = "http://www.example.com"; string requestBodyString = "Request body string."; string contentType = "text/plain"; string requestMethod = "POST"; var request = new ...
using System; using System.IO; using System.Net; using System.Net.Sockets; using System.Text; class TcpChat { static void Main(string[] args) { if(args.Length == 0) { Console.WriteLine("Basic TCP chat"); Console.WriteLine(); ...
using System; using System.IO; using System.Linq; using System.Net.Http; using System.Threading.Tasks; class HttpGet { private static async Task DownloadAsync(string fromUrl, string toFile) { using (var fileStream = File.OpenWrite(toFile)) { using (va...
See RFC 2030 for details on the SNTP protocol. using System; using System.Globalization; using System.Linq; using System.Net; using System.Net.Sockets; class SntpClient { const int SntpPort = 123; static DateTime BaseDate = new DateTime(1900, 1, 1); static void Main(string[...
Say we have a button (we can create it programmatically, or bind it from a view using findViewbyId(), etc...) Button btnOK = (...) Now, create an anonymous class and set it inline. btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ...
When we create a button in layout, we can use the android:onClick attribute to reference a method in code to handle clicks. Button <Button android:width="120dp" android:height="wrap_content" android:text="Click me" android:onClick="handleCl...
When we create any View in layout, we can use the android:onClick attribute to reference a method in the associated activity or fragment to handle the click events. XML Layout <Button android:id="@+id/button" ... // onClick should reference the method in your activity or fra...
Server: Start, and wait for incoming connections //Open a listening "ServerSocket" on port 1234. ServerSocket serverSocket = new ServerSocket(1234); while (true) { // Wait for a client connection. // Once a client connected, we get a "Socket" object // that c...
The Collections class offers two standard static methods to sort a list: sort(List<T> list) applicable to lists where T extends Comparable<? super T>, and sort(List<T> list, Comparator<? super T> c) applicable to lists of any type. Applying the former requires amending...
The shared remote interface: package remote; import java.rmi.Remote; import java.rmi.RemoteException; public interface RemoteServer extends Remote { int stringToInt(String string) throws RemoteException; } The server implementing the shared remote interface: package server; im...
Overview In this example 2 clients send information to each other through a server. One client sends the server a number which is relayed to the second client. The second client halves the number and sends it back to the first client through the server. The first client does the same. The server st...
In order to begin building with PayPal APIs, you have to create an application to obtain a client ID and secret. Go to https://developer.paypal.com/developer/applications/, sign in, and click on "Create App", as shown below: Next, enter an application name, select the sandbox testing a...
This example is a quick setup of Angular 2 and how to generate a quick example project. Prerequisites: Node.js v4 or greater. npm v3 or greater or yarn. Open a terminal and run the commands one by one: npm install -g @angular/cli or yarn global add @angular/cli depending on your choi...
using namespace System; int main(array<String^>^ args) { Console::WriteLine("Hello World"); }
First of all, implement your view holder: implements View.OnClickListener, View.OnLongClickListener Then, register the listeners as follows: itemView.setOnClickListener(this); itemView.setOnLongClickListener(this); Next, override the listeners as follows: @Override public void onClick(Vie...
To catch a long click and use it you need to provide appropriate listener to button: View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { Button clickedButton = (Button) v; String buttonText = clickedButton.getText().toStri...
/** * Enables output buffer streaming. Calling this function * immediately flushes the buffer to the client, and any * subsequent output will be sent directly to the client. */ function _stream() { ob_implicit_flush(true); ob_end_flush(); }

Page 1 of 13