Skip to content

C# Examples

  • Home
  • About C#
    • C# Interview Questions and Answers for .NET Developers
    • Learn C#: A Practical Path Through the Examples
  • All Posts
  • Bootstrap 5 Examples
  • Contact

String Formatting

Format a Number in Scientific Notation in C#

November 25, 2026June 27, 2014 by turgay

Format doubles and integers in scientific (exponential) notation in C# with the E format specifier or custom patterns like 0.##E+0, with culture-safe output.

Categories C# .NET, String Formatting 2 Comments

Indent Strings with Spaces in C#

November 25, 2026June 26, 2014 by turgay

Indent text in C# with new string(‘ ‘, n), PadLeft, alignment in interpolated strings and IndentedTextWriter, including multi-line strings and columns.

Categories C# .NET, String Formatting Tags C#, indent string, indent string with spaces Leave a comment

Convert Numbers to and from Hexadecimal in C#

November 25, 2026June 16, 2014 by turgay

Format integers as hex with the X specifier, parse hex strings back with int.Parse or Convert.ToInt32, and convert byte arrays with Convert.ToHexString.

Categories C# .NET, String Formatting Tags C#, convert, hex value, numeric Leave a comment

Format a DateTime as a String in C#: Custom and Standard Formats

November 25, 2026June 13, 2014 by turgay

Format dates in C# with custom patterns like yyyy-MM-dd and standard formats like “o”, plus a specifier table and the culture traps that change output.

Categories C# .NET, String Formatting Tags datetime, datetime formatting, string formatting Leave a comment

Format a Double in C#: Decimal Places, Padding and Culture

November 25, 2026June 12, 2014 by turgay

Format a double with a fixed or maximum number of decimal places, leading zeros and thousands separators in C#, and avoid the culture and rounding traps.

Categories C# .NET, String Formatting Tags C#, double, string formatting Leave a comment

Categories

Recent Posts

  • Select XML Nodes by Name or Attribute Value in C#
  • Binary Search Tree in C#: Add, Find, Remove and Traversals
  • Select, Insert, Update and Delete Data in an Access File with C#
  • C# Collections: Which One to Use and When
  • C# ArrayList vs Generic List: Examples and When to Use Each
  • About
  • Privacy Policy
  • Contact
© 2026 C# Examples