Tutorial by Examples: c

Some of the simplest kinds of classes are POCOs. // C# public class Person { public string FirstName { get; set; } public string LastName { get; set; } public DateTime Birthday { get; set; } } In F# 3.0, auto-properties similar to C# auto-properties were introduced, // F# typ...
Classes implement an interface to meet the interface's contract. For example, a C# class may implement IDisposable, public class Resource : IDisposable { private MustBeDisposed internalResource; public Resource() { internalResource = new MustBeDisposed(); } ...
A Receiver Operating Characteristic (ROC) curve plots the TP-rate vs. the FP-rate as a threshold on the confidence of an instance being positive is varied Algorithm for creating an ROC curve sort test-set predictions according to confidence that each instance is positive step through ...
If you need to check if your testing method takes too long to execute, you can do that by mentioning your expected execution time using timeout property of @Test annotation. If the test execution takes longer than that number of milliseconds it causes a test method to fail. public class StringConca...
Function contracts allow the programer to check for inconsistencies. Inconsistencies include invalid parameters, checks for the correct return value or an invalid state of the object. The checks can happen before and after the body of the function or method is executed. void printNotGreaterThan42(...
For example if an method is invoked the state of the object may not allow that a method is called with specific parameters or not at all. class OlderThanEighteen { uint age; final void driveCar() in { assert(age >= 18); // variable must be in range } body { ...
Test the application using the development web server, which is included with the App Engine SDK. Run the following Maven command from within your helloworld directory, to compile your app and start the development web server: mvn appengine:devserver The web server is now listening for re...
You can leave the web server running while you develop your application. When you make a change, use the mvn clean package command to build and update your app. Try it now: Leave the web server running, then edit HelloServlet.java to change Hello, world to something else. Run mvn clean package,...
Slices are pointers to arrays, with the length of the segment, and its capacity. They behave as pointers, and assigning their value to another slice, will assign the memory address. To copy a slice value to another, use the built-in copy function: func copy(dst, src []Type) int (returns the amount o...
Package fmt implements formatted I/O using format verbs: %v // the value in a default format %T // a Go-syntax representation of the type of the value %s // the uninterpreted bytes of the string or slice Format Functions There are 4 main function types in fmt and several variations w...
Since Qt 5.5 we have a new wonderful TreeView, a control we've all been waiting for. A TreeView implements a tree representation of items from a model. In general it looks like other QML views - ListView or TableView. But data structure of TreeView is more complex. A data in ListView or TableView...
sort command is used to sort a list of lines. Input from a file sort file.txt Input from a command You can sort any output command. In the example a list of file following a pattern. find * -name pattern | sort
import sympy as sy x, y = sy.symbols("x y") # nsolve needs the (in this case: two) equations, the names of the variables # (x,y) we try to evaluate solutions for, and an initial guess (1,1) for the # solution print sy.nsolve((x**3+sy.exp(y)-4,x+3*y),(x,y),(1,1)) The result s...
myfunc(){ echo "I will never be executed." } another_func(){ # this "redeclare" overwrites original function myfunc(){ echo "I am the one and only"; } } # myfunc will print "I will never be executed" myfunc # but if we call another_func fi...
By default, queries that return entity types are tracking This means you can make changes to those entity instances and have those changes persisted by SaveChanges() Example : The change to the book rating will be detected and persisted to the database during SaveChanges(). using (va...
No tracking queries are useful when the results are used in a read-only scenario They are quicker to execute because there is no need to setup change tracking information Example : using (var context = new BookContext()) { var books = context.Books.AsNoTracking().ToList(); } With ...
Even if the result type of the query isn’t an entity type, if the result contains entity types they will still be tracked by default Example : In the following query, which returns an anonymous type, the instances of Book in the result set will be tracked using (var context = new BookC...
Sometimes we want to give extra information to our user with colors (for example red means something wrong has happened) We can change toast message background color using setting a color filter to the view which our toast give us (here I use a ColorMatrixColorFilter): Toast t = Toast.MakeText(con...
We can change our toast using SetGravity method. This method takes three parameters: first is gravity of toast on screen and two others set toast offset from the starting position (which is set by the first parameter): //Toast at bottom left corner of screen Toast t = Toast.MakeText(context, mess...
Usage To install a module (assuming cpanm is already installed): cpanm Data::Section cpanm ("cpanminus") strives to be less verbose than cpan but still captures all of the installation information in a log file in case it is needed. It also handles many "interactive questions&quo...

Page 578 of 826