Tutorial by Examples: c

An Interface's function known as a "contract" of functionality. It means that it declares properties and methods but it doesn't implement them. So unlike classes Interfaces: Can't be instantiated Can't have any functionality Can only contain methods * (Properties and Events are metho...
Don't you hate it when interfaces pollute you class with too many members you don't even care about? Well I got a solution! Explicit Implementations public interface IMessageService { void OnMessageRecieve(); void SendMessage(); string Result { get; set; } int Encoding { get; se...
Dictionary<TKey, TValue> is a map. For a given key there can be one value in the dictionary. using System.Collections.Generic; var people = new Dictionary<string, int> { { "John", 30 }, {"Mary", 35}, {"Jack", 40} }; // Reading data Console.Wri...
To register your device for push notifications, add the following code to your AppDelegate file in didFinishLaunchingWithOptions method: Swift func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for c...
Strings Array When selecting a value in the select dropdown and providing an array of strings, the selected value will be bound to the select element's value property as a string that we can display using string interpolation. export class MyViewModel { animals = []; favouriteAnimal = nu...
Basic Checkboxes export class MyViewModel { favoriteColors = []; colors = ['Red', 'Yellow', 'Pink', 'Green', 'Purple', 'Orange', 'Blue']; } <template> <label repeat.for="color of colors"> <input type="checkbox" value.bind="color" ch...
When using show.bind the element remains in the page and is either hidden or visible through the use of display:none or display:block behind the scenes. export class MyViewModel { isVisible = false; } <template> <div show.bind="isVisible"><strong>I can be b...
Unlike show.bind when using if.bind the element will be removed from the page if the supplied binding value is false or added into the page if the value is true. export class MyViewModel { isVisible = false; } <template> <div if.bind="isVisible"><strong>If ...
The following are the steps to start an Eclipse remote debugger. This is useful when the application is not started from a server instance within Eclipse. This feature is really powerful and can also help debugging code which resides in the test or production environment. Let's have a look at the se...
The difference in months between two dates can be found using the MONTHS_BETWEEN( date1, date2 ): SELECT MONTHS_BETWEEN( DATE '2016-03-10', DATE '2015-03-10' ) AS difference FROM DUAL; Outputs: DIFFERENCE ---------- 12 If the difference includes part months then it will return the ...
For creating new user, We need to follow simple steps as below : Step 1: Login to MySQL as root $ mysql -u root -p Step 2 : We will see mysql command prompt mysql> CREATE USER 'my_new_user'@'localhost' IDENTIFIED BY 'test_password'; Here, We have successfully created new user, But this u...
we can create a new controller with rails g controller command. $ bin/rails generate controller controller_name The controller generator is expecting parameters in the form of generate controller ControllerName action1 action2. The following creates a Greetings controller with an action of hell...
You can use re.finditer to iterate over all matches in a string. This gives you (in comparison to re.findall extra information, such as information about the match location in the string (indexes): import re text = 'You can try to find an ant in this string' pattern = 'an?\w' # find 'an' either w...
The Windows API GetTickCount function returns the number of milliseconds since the system (computer) was started. The simplest example follows: var Start, Stop, ElapsedMilliseconds: cardinal; begin Start := GetTickCount; // do something that requires measurement Stop := GetTickCount; ...
Appearance : Trying to access an array by a key that does not exist in the array Possible Solution : Check the availability before accessing it. Use: isset() array_key_exists()
Appearance : Happens when your script tries to send a HTTP header to the client but there already was output before, which resulted in headers to be already sent to the client. Possible Causes : Print, echo: Output from print and echo statements will terminate the opportunity to send HTTP hea...
Assume an application with a MainActivity which can call the Next Activity using a button click. public class MainActivity extends AppCompatActivity { private final String LOG_TAG = MainActivity.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { ...
The below code example will give you an adjusted version of that color where a higher percentage will be brighter and a lower percentage will be darker. Objective-C + (UIColor *)adjustedColorForColor:(UIColor *)c : (double)percent { if (percent < 0) percent = 0; CGFloat r, g, b...
Pan gesture recognizers detect dragging gestures. The following example adds an image to a view controller and lets the user drag it around on screen. Objective-C - (void)viewDidLoad { [super viewDidLoad]; UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNa...
When performing tasks asynchronously there typically becomes a need to ensure a piece of code is run on the main thread. For example you may want to hit a REST API asynchronously, but put the result in a UILabel on the screen. Before updating the UILabel you must ensure that your code is run on th...

Page 287 of 826