Tutorial by Examples: dto

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...
If you are using the PASSWORD_DEFAULT method to let the system choose the best algorithm to hash your passwords with, as the default increases in strength you may wish to rehash old passwords as users log in <?php // first determine if a supplied password is valid if (password_verify($plaintex...
If you have already added a file to your Git repository and now want to stop tracking it (so that it won't be present in future commits), you can remove it from the index: git rm --cached <file> This will remove the file from the repository and prevent further changes from being tracked by...
First, establish if the device is capable of accepting Touch ID input. if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)) If it does then we can display the Touch ID UI by using: context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometri...
A lookbehind can be used at the end of a pattern to ensure it ends or not in a certain way. ([a-z ]+|[A-Z ]+)(?<! ) matches sequences of only lowercase or only uppercase words while excluding trailing whitespace.
SELECT your_columns, COUNT(*) OVER() as Ttl_Rows FROM your_data_set idnameTtl_Rows1example52foo53bar54baz55quux5 Instead of using two queries to get a count then the line, you can use an aggregate as a window function and use the full result set as the window. This can be used as a base for fur...
Named methods can be assigned to delegates with matching signatures: public static class Example { public static int AddOne(int input) { return input + 1; } } Func<int,int> addOne = Example.AddOne Example.AddOne takes an int and returns an int, its signature ...
execute the following command to insert the text into a view with a focus (if it supports text input) 6.0 Send text on SDK 23+ adb shell "input keyboard text 'Paste text on Android Device'" If already connected to your device via adb: input text 'Paste text on Android Device' 6...
git difftool -t meld --dir-diff will show the working directory changes. Alternatively, git difftool -t meld --dir-diff [COMMIT_A] [COMMIT_B] will show the differences between 2 specific commits.
async functions do not replace the Promise type; they add language keywords that make promises easier to call. They are interchangeable: async function doAsyncThing() { ... } function doPromiseThing(input) { return new Promise((r, x) => ...); } // Call with promise syntax doAsyncThing() ...
Swift import SystemConfiguration /// Class helps to code reuse in handling internet network connections. class NetworkHelper { /** Verify if the device is connected to internet network. - returns: true if is connected to any internet network, false if is not co...
Sometimes, programmers who are new Java will use primitive types and wrappers interchangeably. This can lead to problems. Consider this example: public class MyRecord { public int a, b; public Integer c, d; } ... MyRecord record = new MyRecord(); record.a = 1; // OK ...
When you use or, it will either return the first value in the expression if it's true, else it will blindly return the second value. I.e. or is equivalent to: def or_(a, b): if a: return a else: return b For and, it will return its first value if it's false, else it r...
You can bind to a property on a named element, but the named element must be in scope. <StackPanel> <CheckBox x:Name="MyCheckBox" IsChecked="True" /> <TextBlock Text="{Binding IsChecked, ElementName=MyCheckBox}" /> </StackPanel>
You can bind to a property of an ancestor in the visual tree by using a RelativeSource binding. The nearest control higher in the visual tree which has the same type or is derived from the type you specify will be used as the binding's source: <Grid Background="Blue"> <Grid ...
If you fetch a single record and when that record has a lookup, you can also fetch values of the lookup value using the expand option. This reduces the number of calls you need to make to the API. The sample gets all accounts and the last name of the primary contact: $.ajax({ url: Xrm.Page.co...
File app.routes Protected routes have canActivate binded to Guard import { provideRouter, Router, RouterConfig, CanActivate } from '@angular/router'; //components import { LoginComponent } from './login/login.component'; import { DashboardComponent } from './dashboard/dashboard.component'; ...
Assuming we want to modify bit n of an integer primitive, i (byte, short, char, int, or long): (i & 1 << n) != 0 // checks bit 'n' i |= 1 << n; // sets bit 'n' to 1 i &= ~(1 << n); // sets bit 'n' to 0 i ^= 1 << n; // toggles the value of bit 'n' Us...
The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...

Page 1 of 7