Tutorial by Examples

Add days into a dateTime object. DateTime today = DateTime.Now; DateTime answer = today.AddDays(36); Console.WriteLine("Today: {0:dddd}", today); Console.WriteLine("36 days from today: {0:dddd}", answer); You also can subtract days passing a negative value: DateTime today...
double[] hours = {.08333, .16667, .25, .33333, .5, .66667, 1, 2, 29, 30, 31, 90, 365}; DateTime dateValue = new DateTime(2009, 3, 1, 12, 0, 0); foreach (double hour in hours) Console.WriteLine("{0} + {1} hour(s) = {2}", dateValue, hour, ...
string dateFormat = "MM/dd/yyyy hh:mm:ss.fffffff"; DateTime date1 = new DateTime(2010, 9, 8, 16, 0, 0); Console.WriteLine("Original date: {0} ({1:N0} ticks)\n", date1.ToString(dateFormat), date1.Ticks); DateTime date2 = date1.AddMilliseconds(1); Console....
DateTime date1 = new DateTime(2009, 8, 1, 0, 0, 0); DateTime date2 = new DateTime(2009, 8, 1, 12, 0, 0); int result = DateTime.Compare(date1, date2); string relationship; if (result < 0) relationship = "is earlier than"; else if (result == 0) relationship = "is the...
const int July = 7; const int Feb = 2; int daysInJuly = System.DateTime.DaysInMonth(2001, July); Console.WriteLine(daysInJuly); // daysInFeb gets 28 because the year 1998 was not a leap year. int daysInFeb = System.DateTime.DaysInMonth(1998, Feb); Console.WriteLine(daysInFeb); // daysIn...
Add years on the dateTime object: DateTime baseDate = new DateTime(2000, 2, 29); Console.WriteLine("Base Date: {0:d}\n", baseDate); // Show dates of previous fifteen years. for (int ctr = -1; ctr >= -15; ctr--) Console.WriteLine("{0,2} year(s) ago:{1:d}", ...
Once the instance of the BackgroundWorker has been declared, it must be given properties and event handlers for the tasks it performs. /* This is the backgroundworker's "DoWork" event handler. This method is what will contain all the work you wish to have your progra...
This allows the BackgroundWorker to be cancelled in between tasks bgWorker.WorkerSupportsCancellation = true; This allows the worker to report progress between completion of tasks... bgWorker.WorkerReportsProgress = true; //this must also be used in conjunction with the ProgressChanged event...
A BackgroundWorker is commonly used to perform tasks, sometimes time consuming, without blocking the UI thread. // BackgroundWorker is part of the ComponentModel namespace. using System.ComponentModel; namespace BGWorkerExample { public partial class ExampleForm : Form { ...
The following example demonstrates the use of a BackgroundWorker to update a WinForms ProgressBar. The backgroundWorker will update the value of the progress bar without blocking the UI thread, thus showing a reactive UI while work is done in the background. namespace BgWorkerExample { public...
Python supports a translate method on the str type which allows you to specify the translation table (used for replacements) as well as any characters which should be deleted in the process. str.translate(table[, deletechars]) ParameterDescriptiontableIt is a lookup table that defines the mappin...
application-name Giving the name of the Web application that the page represents. <meta name="application-name" content="OpenStreetMap"> If it’s not a Web application, the application-name meta tag must not be used. author Set the author of the page: <meta name=&...
Elements come with angle brackets are the most prominent building block of XML. Elements can either be empty, in which case they are made of an empty tag (notice the ending slash): <an-empty-element/> Or they can have content, in which case they have an opening tag (no slash) and a closin...
The foreach package brings the power of parallel processing to R. But before you want to use multi core CPUs you have to assign a multi core cluster. The doSNOW package is one possibility. A simple use of the foreach loop is to calculate the sum of the square root and the square of all numbers from...
Properties can be added with categories using associated objects, a feature of the Objective-C runtime. Note that the property declaration of retain, nonatomic matches the last argument to objc_setAssociatedObject. See Attach object to another existing object for explanations. #import <objc/run...
Extension methods are useful to extend the behaviour of libraries we don't own. They are used similar to instance methods thanks to the compiler's syntactic sugar: Sub Main() Dim stringBuilder = new StringBuilder() 'Extension called directly on the object. stringBuilder.AppendIf(t...
A good use of extension method is to make the language more functional Sub Main() Dim strings = { "One", "Two", "Three" } strings.Join(Environment.NewLine).Print() End Sub <Extension> Public Function Join(strings As IEnumerable(Of String), separa...
A namespace is a URI, but to avoid verbosity, prefixes are used as a proxy. In the following example, the prefix my-prefix is bound to the namespace http://www.example.com/my-namespace by using the special attribute xmlns:my-prefix (my-prefix can be replaced with any other prefix): <?xml versio...
In XML, element and attribute names live in namespaces. By default, they are in no namespace: <?xml version="1.0"?> <foo attr="value"> <!-- the foo element is in no namespace, neither is the attr attribute --> </foo>
These two documents are semantically equivalement, as namespaces matter, not prefixes. <?xml version="1.0"?> <myns:foo xmlns:myns="http://www.example.com/my-namespace"> </myns:foo> <?xml version="1.0"?> <ns:foo xmlns:ns="http://www...

Page 194 of 1336