Tutorial by Examples: converti

public class IHtmlStringTypeHandler : SqlMapper.TypeHandler<IHtmlString> { public override void SetValue( IDbDataParameter parameter, IHtmlString value) { parameter.DbType = DbType.String; parameter.Value = value?.ToHtmlString(); } pu...
You can get the value of other primitive data types as a String using one the String class's valueOf methods. For example: int i = 42; String string = String.valueOf(i); //string now equals "42”. This method is also overloaded for other datatypes, such as float, double, boolean, and ...
format() from SimpleDateFormat class helps to convert a Date object into certain format String object by using the supplied pattern string. Date today = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy"); //pattern is specified here System.out.println(date...
parse() from SimpleDateFormat class helps to convert a String pattern into a Date object. DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); String dateStr = "02/25/2016"; // input String Date date = dateFormat.parse(dateStr); System.out.println(date.getYe...
JavaScript has two primary ways to represent binary data in the browser. ArrayBuffers/TypedArrays contain mutable (though still fixed-length) binary data which you can directly manipulate. Blobs contain immutable binary data which can only be accessed through the asynchronous File interface. Conver...
Number('0') === 0 Number('0') will convert the string ('0') into a number (0) A shorter, but less clear, form: +'0' === 0 The unary + operator does nothing to numbers, but converts anything else to a number. Interestingly, +(-12) === -12. parseInt('0', 10) === 0 parseInt('0', 10) will c...
String(0) === '0' String(0) will convert the number (0) into a string ('0'). A shorter, but less clear, form: '' + 0 === '0'
An array can easily be converted into a std::vector by using std::begin and std::end: C++11 int values[5] = { 1, 2, 3, 4, 5 }; // source array std::vector<int> v(std::begin(values), std::end(values)); // copy array to new vector for(auto &x: v) std::cout << x << &q...
What are Array-like Objects? JavaScript has "Array-like Objects", which are Object representations of Arrays with a length property. For example: var realArray = ['a', 'b', 'c']; var arrayLike = { 0: 'a', 1: 'b', 2: 'c', length: 3 }; Common examples of Array-like Objects...
You may need to convert a Stream emitting Optional to a Stream of values, emitting only values from existing Optional. (ie: without null value and not dealing with Optional.empty()). Optional<String> op1 = Optional.empty(); Optional<String> op2 = Optional.of("Hello World");...
Given a String: s = "something" there are several ways to convert it to a Symbol: s.to_sym # => :something :"#{s}" # => :something
Given a Symbol: s = :something The simplest way to convert it to a String is by using the Symbol#to_s method: s.to_s # => "something" Another way to do it is by using the Symbol#id2name method which is an alias for the Symbol#to_s method. But it's a method that is unique to the...
You can use the Integer method to convert a String to an Integer: Integer("123") # => 123 Integer("0xFF") # => 255 Integer("0b100") # => 4 Integer("0555") # => 365 You can also pass a base parameter to the Integer method to c...
NSArray *myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; // Convert myColors to mutable NSMutableArray *myColorsMutable = [myColors mutableCopy];
Fixnum#to_s takes an optional base argument and represents the given number in that base: 2.to_s(2) # => "10" 3.to_s(2) # => "11" 3.to_s(3) # => "10" 10.to_s(16) # => "a" If no argument is provided, then it represents the number in bas...
Sometimes it's necessary to convert a Discriminated Union to and from a string: module UnionConversion open Microsoft.FSharp.Reflection let toString (x: 'a) = match FSharpValue.GetUnionFields(x, typeof<'a>) with | case, _ -> case.Name let fromStri...
NSSet *set = [NSSet set]; NSArray *array = [NSArray array]; NSArray *fromSet = [set allObjects]; NSSet *fromArray = [NSSet setWithArray:array];
In normal mode: ~ inverts the case of the character under the cursor, gu{motion} lowercases the text covered by {motion}, gU{motion} uppercases the text covered by {motion} Example (^ marks the cursor position): Lorem ipsum dolor sit amet. ^ Lorem ipSum dolor sit amet. ~ Lorem...
Boolean(0) === false Boolean(0) will convert the number 0 into a boolean false. A shorter, but less clear, form: !!0 === false
To convert a string to boolean use Boolean(myString) or the shorter but less clear form !!myString All strings except the empty string (of length zero) are evaluated to true as booleans. Boolean('') === false // is true Boolean("") === false // is true Boolean('0') === fals...

Page 1 of 4