Tutorial by Examples: ante

String.Trim() string x = " Hello World! "; string y = x.Trim(); // "Hello World!" string q = "{(Hi!*"; string r = q.Trim( '(', '*', '{' ); // "Hi!" String.TrimStart() and String.TrimEnd() string q = "{(Hi*"; string r = q.TrimStart( '{...
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...
function meridiem(d:Date):String { return (d.hours > 11) ? "pm" : "am"; }
C++17 Normally, elision is an optimization. While virtually every compiler support copy elision in the simplest of cases, having elision still places a particular burden on users. Namely, the type who's copy/move is being elided must still have the copy/move operation that was elided. For example:...
Three methods are provided that offer the ability to strip leading and trailing characters from a string: str.strip, str.rstrip and str.lstrip. All three methods have the same signature and all three return a new string object with unwanted characters removed. str.strip([chars]) str.strip acts o...
As a developer, you frequently find yourself dealing with strings that are not created by your own code. These will often be supplied by third party libraries, external systems, or even end users. Validating strings of unclear provenance is considered to be one of the hallmarks of defensive program...
Inspired by PowerShell: Function doesn't have proper return value function bar { [System.Collections.ArrayList]$MyVariable = @() $MyVariable.Add("a") | Out-Null $MyVariable.Add("b") | Out-Null $MyVariable } The Out-Null is necessary because the .NET ArrayLis...
The revert command allows discarding unwanted uncommitted changes. Reverting changes to a single file. hg revert example.c Reverting all changes. This will discard all changes not just the current directory. hg revert --all hg will output which files were reverted. reverting exa...
The example Checking a string for unwanted characters, describes how to test and reject strings that don't meet certain criteria. Obviously, rejecting input outright is not always possible, and sometimes you just have to make do with what you receive. In these cases, a cautious developer will attemp...
To change a text file is not easy because its content must be moved around. For small files easiest method is to read its content in memory and then write back modified text. In this example we read all lines from a file and drop all blank lines then we write back to original path: File.WriteAllLi...
ConstantExpression must be the same type of the MemberExpression. The value in this example is a string, which is converted before creating the ConstantExpression instance. private static ConstantExpression GetConstant(Type type, string value) { // Discover the type, convert it, and create Co...
A constant expression is an expression that yields a primitive type or a String, and whose value can be evaluated at compile time to a literal. The expression must evaluate without throwing an exception, and it must be composed of only the following: Primitive and String literals. Type ca...
From Xcode menu open: Product > Scheme > Edit Scheme. On your Environment Variables set OS_ACTIVITY_MODE = disable

Page 1 of 1