HomeSearch

C# Convert Types

Call built-in methods, and more complex custom ones, to convert types like Lists and arrays.
Convert. Day converts to night. Warmth and sunshine transforms into a bitter dark coldness. Everything in our existence is in constant motion and change.
Conversion list. Types too can change into other types. The day (think of a List) can turn into the night (a String). Conversions are a key part of programs.2D Array to 1D ArrayArray to ListArray to StringArrayList to ArrayArrayList to ListBool to IntByte Array to IntByte Array to Base64 StringByte Array to BinaryReaderChar Array to StringChar to StringClass to InterfaceDateTime to StringDictionary to StringDouble to IntEnum to StringInt to BoolInt to ByteInt to CharInt to LongList to ArrayList to DictionaryList to DataTableList to StringObject to StringString Array to StringString to BoolString to Byte ArrayString to Char ArrayString to DateTimeString to EnumString to GZIPString to IntTimeSpan to LongTuple to ValueTuple
Numeric. Most numeric conversions involve a multiplication or division expression. We cannot convert time itself, but we can change its units. Here are some reusable unit conversions.Bytes to MegabytesCelsius to FahrenheitDays to MonthsFeet to InchesMiles to KilometersMilliseconds to SecondsNanoseconds to Milliseconds
LINQ. Conversion methods are found throughout this site. Consider the LINQ extensions: some methods, like Distinct, perform a conversion that removes duplicates.LINQLINQ: DistinctLINQ: ToArrayLINQ: ToDictionaryLINQ: ToList
A summary. Casting is a form of conversion. But more complex conversions, like we find in LINQ, are also available in the C# language.Casts
© 2007-2020 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.
Home
Dot Net Perls