Tutorial by Examples: app

Either search in the Visual Studio GUI: Tools > NuGet Package Manager > Manage Packages for Solution... (Visual Studio 2015) Or run this command in a Nuget Power Shell instance to install the latest stable version Install-Package Dapper Or for a specific version Install-Package Dapper...
using System.Data; using System.Linq; using Dapper; class Program { static void Main() { using (IDbConnection db = new SqlConnection("Server=myServer;Trusted_Connection=true")) { db.Open(); var result = db.Query<string>(&quo...
LINQPad is great for testing database queries and includes NuGet integration. To use Dapper in LINQPad press F4 to open the Query Properties and then select Add NuGet. Search for dapper dot net and select Add To Query. You will also want to click Add namespaces and highlight Dapper to include the Ex...
Open Visual Studio In the toolbar, go to File → New Project Select the Console Application project type Open the file Program.cs in the Solution Explorer Add the following code to Main(): public class Program { public static void Main() { // Prints a message to the conso...
Deprecated usage The ConfigurationSettings class was the original way to retrieve settings for an assembly in .NET 1.0 and 1.1. It has been superseded by the ConfigurationManager class and the WebConfigurationManager class. If you have two keys with the same name in the appSettings section of the ...
The ConfigurationManager class supports the AppSettings property, which allows you to continue reading settings from the appSettings section of a configuration file the same way as .NET 1.x supported. app.config <?xml version="1.0" encoding="utf-8"?> <configuration&gt...
Visual Studio helps manage user and application settings. Using this approach has these benefits over using the appSettings section of the configuration file. Settings can be made strongly typed. Any type which can be serialized can be used for a settings value. Application settings can be...
Given an async method like this: Task<string> GetNameAsync(CancellationToken cancellationToken) Wrap it as an IObservable<string> like this: Observable.FromAsync(cancellationToken => GetNameAsync(cancellationToken))
Snippet public class SomeClass<TItem> { public void PrintTypeName() { Console.WriteLine(nameof(TItem)); } } ... var myClass = new SomeClass<int>(); myClass.PrintTypeName(); Console.WriteLine(nameof(SomeClass<int>)); Console Output TItem S...
Snippet Console.WriteLine(nameof(CompanyNamespace.MyNamespace)); Console.WriteLine(nameof(MyClass)); Console.WriteLine(nameof(MyClass.MyNestedClass)); Console.WriteLine(nameof(MyNamespace.MyClass.MyNestedClass.MyStaticProperty)); Console Output MyNamespace MyClass MyNestedClass MyStatic...
The AppCompat support library provides themes to build apps with the Material Design specification. A theme with a parent of Theme.AppCompat is also required for an Activity to extend AppCompatActivity. The first step is to customize your theme’s color palette to automatically colorize your app. I...
Annotation @XmlAccessorType determines whether fields/properties will be automatically serialized to XML. Note, that field and method annotations @XmlElement, @XmlAttribute or @XmlTransient take precedence over the default settings. public class XmlAccessTypeExample { @XmlAccessorType(XmlAccessT...
Annotations @XmlElement, @XmlAttribute or @XmlTransient and other in package javax.xml.bind.annotation allow the programmer to specify which and how marked fields or properties should be serialized. @XmlAccessorType(XmlAccessType.NONE) // we want no automatic field/property marshalling public cla...
It is often necessary to generate a new array based on the values of an existing array. For example, to generate an array of string lengths from an array of strings: 5.1 ['one', 'two', 'three', 'four'].map(function(value, index, arr) { return value.length; }); // → [3, 3, 5, 4] 6 ['one...
The JSONSerialization class is built into Apple's Foundation framework. 2.2 Read JSON The JSONObjectWithData function takes NSData, and returns AnyObject. You can use as? to convert the result to your expected type. do { guard let jsonData = "[\"Hello\", \"JSON\"]&q...
This example assumes Ruby and Ruby on Rails have already been installed properly. If not, you can find how to do it here. Open up a command line or terminal. To generate a new rails application, use rails new command followed by the name of your application: $ rails new my_app If you want to c...
In order to access the value of an Optional, it needs to be unwrapped. You can conditionally unwrap an Optional using optional binding and force unwrap an Optional using the ! operator. Conditionally unwrapping effectively asks "Does this variable have a value?" while force unwrapping sa...
Direction-Specific Properties CSS allows you to specify a given side to apply margin to. The four properties provided for this purpose are: margin-left margin-right margin-top margin-bottom The following code would apply a margin of 30 pixels to the left side of the selected div. View Resu...
One method is available for counting the number of occurrences of a sub-string in another string, str.count. str.count(sub[, start[, end]]) str.count returns an int indicating the number of non-overlapping occurrences of the sub-string sub in another string. The optional arguments start and end ...
For example, you can take the absolute value of each element: list(map(abs, (1, -1, 2, -2, 3, -3))) # the call to `list` is unnecessary in 2.x # Out: [1, 1, 2, 2, 3, 3] Anonymous function also support for mapping a list: map(lambda x:x*2, [1, 2, 3, 4, 5]) # Out: [2, 4, 6, 8, 10] or convert...

Page 1 of 33