Tutorial by Examples: c

This class is called Greeter. Its responsibility is to output a greeting. It has two dependencies. It needs something that will give it the greeting to output, and then it needs a way to output that greeting. Those dependencies are both described as interfaces, IGreetingProvider and IGreetingWriter....
This builds on the previous example of the Greeter class which has two dependencies, IGreetingProvider and IGreetingWriter. The actual implementation of IGreetingProvider might retrieve a string from an API call or a database. The implementation of IGreetingWriter might display the greeting in the ...
Dependency injection means writing classes so that they do not control their dependencies - instead, their dependencies are provided to them ("injected.") This is not the same thing as using a dependency injection framework (often called a "DI container", "IoC container&quo...
Add the I18N nuget package to your MVC project. In web.config, add the i18n.LocalizingModule to your <httpModules> or <modules> section. <!-- IIS 6 --> <httpModules> <add name="i18n.LocalizingModule" type="i18n.LocalizingModule, i18n" /> &...
The java.util.Locale class is used to represent a "geographical, political or cultural" region to localize a given text, number, date or operation to. A Locale object may thus contain a country, region, language, and also a variant of a language, for instance a dialect spoken in a certain ...
Unnamed struct is allowed (type has no name) void foo() { struct /* No name */ { float x; float y; } point; point.x = 42; } or struct Circle { struct /* No name */ { float x; float y; } center; // but a member name float...
This is an example of how to implement custom parameter converters for JAX-RS endpoints. The example shows two classes from Java 8's java.time library. @Provider public class ParamConverters implements ParamConverterProvider { @Override public <T> ParamConverter<T> getConverter...
Connection factories are the managed objects that allows application to connect to provider by creating Connection object. javax.jms.ConnectionFactory is an interface that encapsulates configuration parameters defined by an administrator. For using ConnectionFactory client must execute JNDI lookup ...
var bufferBlock = new BufferBlock<int>(new DataflowBlockOptions { BoundedCapacity = 1000 }); var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token; var producerTask = Task.Run(async () => { var random = new Random(); while (!cancellati...
The Reflection API could be used to change values of private and final fields even in the JDK default library. This could be used to manipulate the behaviour of some well known classes as we will see. What is not possible Lets start first with the only limitation means the only field we can't chan...
The @switch annotation tells the compiler that the match statement can be replaced with a single tableswitch instruction at the bytecode level. This is a minor optimization that can remove unnecessary comparisons and variable loads during runtime. The @switch annotation works only for matches again...
Most KVO and KVC functionality is already implemented by default on all NSObject subclasses. To start observing a property named firstName of an object named personObject do this in the observing class: [personObject addObserver:self forKeyPath:@"firstName" ...
Objective-C NSURL *url = [[NSURL alloc] initWithString:@"YOUR URL"]; // url can be remote or local AVPlayer *player = [AVPlayer playerWithURL:url]; // create a player view controller AVPlayerViewController *controller = [[AVPlayerViewController alloc] init]; [self presentViewC...
This example shows the behaviour of getopt when the user input is uncommon: getopt.php var_dump( getopt("ab:c::", ["delta", "epsilon:", "zeta::"]) ); Shell command line $ php getopt.php -a -a -bbeta -b beta -cgamma --delta --epsilon --zeta --zeta=f...
You can execute a database query from a String rather than a regular SOQL expression: String tableName = 'Account'; String queryString = 'SELECT Id FROM ' + tableName + ' WHERE CreatedDate >= YESTERDAY'; List<SObject> objects = Database.query(queryString); Since dynamic SOQL queries a...
PHP can also be run from command line directly using the CLI (Command Line Interface). CLI is basically the same as PHP from web servers, except some differences in terms of standard input and output. Triggering The PHP CLI allows four ways to run PHP code: Standard input. Run the php command ...
Basically you can use type inference whenever it is possible. However, be careful when combining Option Infer Off and Option Strict Off, as this can lead to undesired run-time behavior: Dim someVar = 5 someVar.GetType.ToString() '--> System.Int32 someVar = "abc" someVar.GetType.To...
Sub Main() Dim People = New List(Of String)({"Bob Barker", "Ricky Bobby", "Jeff Bridges"}) Console.WriteLine(People.Contains("Rick James")) Console.WriteLine(People.Contains("Ricky Bobby")) Console.WriteLine(Pe...
There are three ways to create a graphics object From the Paint Event Every time the control is redrawn (resized, refreshed...) this event is called, use this way if you want the control to consistently draw on the control 'this will work on any object's paint event, not just the form ...
SQL Server 2016 Escapes special characters in texts and returns text (nvarchar(max)) with escaped characters. Parameters: text. is a nvarchar expression representing the string that should be escaped. type. Escaping rules that will be applied. Currently the only supported value is 'json'...

Page 433 of 826