Tutorial by Examples: acl

public class Animal { public string Name { get; set; } } public interface INoiseMaker { string MakeNoise(); } //Note that in C#, the base class name must come before the interface names public class Cat : Animal, INoiseMaker { public Cat() { Name = "Ca...
public class LivingBeing { string Name { get; set; } } public interface IAnimal { bool HasHair { get; set; } } public interface INoiseMaker { string MakeNoise(); } //Note that in C#, the base class name must come before the interface names public class Cat : LivingBei...
6.0 Allows you to import a specific type and use the type's static members without qualifying them with the type name. This shows an example using static methods: using static System.Console; // ... string GetName() { WriteLine("Enter your name."); return ReadLine(); } ...
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...
You can define a new class using the class keyword. class MyClass end Once defined, you can create a new instance using the .new method somevar = MyClass.new # => #<MyClass:0x007fe2b8aa4a18>
When type is called with three arguments it behaves as the (meta)class it is, and creates a new instance, ie. it produces a new class/type. Dummy = type('OtherDummy', (), dict(x=1)) Dummy.__class__ # <type 'type'> Dummy().__class__.__class__ # <type 'type'> It is po...
A singleton is a pattern that restricts the instantiation of a class to one instance/object. For more info on python singleton design patterns, see here. class SingletonType(type): def __call__(cls, *args, **kwargs): try: return cls.__instance except AttributeErr...
You define a class like this: class Dog {} A class can also be a subclass of another class: class Animal {} class Dog: Animal {} In this example, Animal could also be a protocol that Dog conforms to.
Classes are identifiers for the elements that they are assigned to. Use the class attribute to assign a class to an element. <div class="example-class"></div> To assign multiple classes to an element, separate the class names with spaces. <div class="class1 class2&...
As shown in Declaring Namespaces, we can define a class in a namespace as follows: namespace MyProject\Shapes; class Rectangle { ... } To reference this class the full path (including the namespace) needs to be used: $rectangle = new MyProject\Shapes\Rectangle(); This can be shortened by ...
A class can be defined using classdef in an .m file with the same name as the class. The file can contain the classdef...end block and local functions for use within class methods. The most general MATLAB class definition has the following structure: classdef (ClassAttribute = expression, ...) Cla...
5.0 In PowerShell 5.0+ you can list available constructors by calling the static new-method without parentheses. PS> [DateTime]::new OverloadDefinitions ------------------- datetime new(long ticks) datetime new(long ticks, System.DateTimeKind kind) datetime new(int year, int month, int d...
Header file UIColor+XYZPalette.h: @interface UIColor (XYZPalette) +(UIColor *)xyz_indigoColor; @end and implementation UIColor+XYZPalette.m: @implementation UIColor (XYZPalette) +(UIColor *)xyz_indigoColor { return [UIColor colorWithRed:75/255.0f green:0/255.0f blue:130/255.0f al...
const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.question('What is your name?', (name) => { console.log(`Hello ${name}!`); rl.close(); });
Abstract classes are classes that are meant to be inherited but avoid implementing specific methods, leaving behind only method signatures that subclasses must implement. Abstract classes are useful for defining and enforcing class abstractions at a high level, similar to the concept of interfaces ...
Enumerable is the most popular module in Ruby. Its purpose is to provide you with iterable methods like map, select, reduce, etc. Classes that use Enumerable include Array, Hash, Range. To use it, you have to include Enumerable and implement each. class NaturalNumbers include Enumerable de...
Classes can be created as follow: class InputField { int maxLength; String name; } The class can be instantiated using the new keyword after which the field values will be null by default. var field = new InputField(); Field values can then be accessed: // this will trigger the sette...
Imports System.Reflection Public Class PropertyExample Public Function GetMyProperties() As PropertyInfo() Dim objProperties As PropertyInfo() objProperties = Me.GetType.GetProperties(BindingFlags.Public Or BindingFlags.Instance) Return objProperties End Fun...
Oracle's CONNECT BY functionality provides many useful and nontrivial features that are not built-in when using SQL standard recursive CTEs. This example replicates these features (with a few additions for sake of completeness), using SQL Server syntax. It is most useful for Oracle developers findin...
Managed resources are resources that the runtime's garbage collector is aware and under control of. There are many classes available in the BCL, for example, such as a SqlConnection that is a wrapper class for an unmanaged resource. These classes already implement the IDisposable interface -- it's u...

Page 1 of 6