tagged [string-formatting]
How to pad a binary string with zeros?
How to pad a binary string with zeros? Prints: `1111` I want it to print `00001000` Because the data type is of string and not integer I cannot do something like this:
- Modified
- 7 Oct at 02:57
Named placeholders in string formatting
Named placeholders in string formatting In Python, when formatting string, I can fill placeholders by name rather than by position, like that: I wonder if that is possible in Java (hopefully, without ...
- Modified
- 27 Nov at 22:33
Using variables inside strings
Using variables inside strings In PHP I can do the following: Is there a similar language construct in C#? I know there is `String.Format();` but I want to know if it can be done without calling a fun...
- Modified
- 12 Dec at 19:45
String.Format for Hex
String.Format for Hex With below code, the colorsting always gives #DDDD. Green, Red and Space values int he How to fix this?
- Modified
- 27 Nov at 22:28
Generate fixed length Strings filled with whitespaces
Generate fixed length Strings filled with whitespaces I need to produce fixed length string to generate a character position based file. The missing characters must be filled with space character. As ...
- Modified
- 12 Feb at 14:25
How do I turn a python datetime into a string, with readable format date?
How do I turn a python datetime into a string, with readable format date? How do I turn that into a string?:
- Modified
- 28 Jan at 22:20
How can I format a number into a string with leading zeros?
How can I format a number into a string with leading zeros? I have a number that I need to convert to a string. First I used this: But I realize it's being sorted in a strange order and so I need to p...
- Modified
- 27 Mar at 09:51
How to put unprocessed (escaped) words inside String.Format
How to put unprocessed (escaped) words inside String.Format I am formatting a date: I want to put the word "at" after the "d", but I don't want the string to format it. I just want the word "at". How ...
- Modified
- 26 May at 18:19
StringFormat on Binding
StringFormat on Binding View: I want to format the Date to "dd/MM/yyyy", in other words, without the time. I tried it: ``, but it doesn't work. Gives me an error: The property 'StringFormat' was not f...
- Modified
- 5 Jul at 07:55
What does %s mean in a Python format string?
What does %s mean in a Python format string? What does `%s` mean in Python? And what does the following bit of code do? For instance... ``` if len(sys.argv)
- Modified
- 1 Mar at 15:43
Add to string if string non empty
Add to string if string non empty Sometime I want to join two strings with a space in between. But if second string is null, I don't want the space. Consider following code: Is there a more elegant wa...
- Modified
- 25 Sep at 18:35
Calculate a Ratio in C#
Calculate a Ratio in C# I thought this would be simple, but searching Google didn't seem to help. I'm basically trying to write a function which will return a ratio as a string (eg 4:3) when supplies ...
- Modified
- 26 Dec at 15:52
How can I fill out a Python string with spaces?
How can I fill out a Python string with spaces? I want to fill out a string with spaces. I know that the following works for zero's: But what should I do when I want this?: of course I can measure str...
- Modified
- 13 Feb at 06:2
Is there a "String.Format" that can accept named input parameters instead of index placeholders?
Is there a "String.Format" that can accept named input parameters instead of index placeholders? This is what I know But I want something like
- Modified
- 21 Apr at 04:56
Turn byte into two-digit hexadecimal number just using ToString?
Turn byte into two-digit hexadecimal number just using ToString? I can turn a byte into a hexadecimal number like this: but it will have only one digit if it is less than 0x10. I need it with a leadin...
- Modified
- 24 Mar at 23:3
C# date formatting is losing slash separators
C# date formatting is losing slash separators If I do this in C#: I would expect output like this: But it actually outputs this: Why are the slashes disappearing? Is there a way to prevent this and ha...
- Modified
- 15 Jun at 17:56
How to show a comma separated number with StringFormat in XAML?
How to show a comma separated number with StringFormat in XAML? My code currently shows like this: `43521 reviews`, I want it be like this: `43,521 reviews`. How can I do that? and is there a full ref...
- Modified
- 10 Mar at 09:11
C# String Format for hours and minutes from decimal
C# String Format for hours and minutes from decimal Is there a simple string format that will take a decimal representing hours and fractions of hours and show it as hours and minutes? For example : 5...
- Modified
- 1 May at 23:56
Display Float as String with at Least 1 Decimal Place
Display Float as String with at Least 1 Decimal Place I want to display a float as a string while making sure to display at least one decimal place. If there are more decimals I would like those displ...
- Modified
- 7 Nov at 16:0
php Replacing multiple spaces with a single space
php Replacing multiple spaces with a single space I'm trying to replace multiple spaces with a single space. When I use `ereg_replace`, I get an error about it being deprecated. Is there an identical ...
- Modified
- 15 Sep at 08:7
What does {0} mean when found in a string in C#?
What does {0} mean when found in a string in C#? In a dictionary like this: The output is: > For Key
- Modified
- 15 Jan at 12:17
How to use string interpolation in a resource file?
How to use string interpolation in a resource file? I would like to use a resource file to send an email. In my resource file I used a variable "EmailConfirmation" with the value "Hello {userName} ......
- Modified
- 18 Feb at 14:12
Format Strings in Console.WriteLine method
Format Strings in Console.WriteLine method Im new to C# programming. Can someone please explain the following code: I understand that this prints two columns of values with the headings given, and `{0...
- Modified
- 6 Jul at 09:15
Formatting a string with string.Format("{0:00}"
Formatting a string with string.Format("{0:00}" I have just taken over some code and I see this used a lot. It seems to take the integer and create a string looking like "01", "02" etc. What I am not ...
- Modified
- 17 Oct at 03:42
Decimal stores precision from parsed string in C#? What are the implications?
Decimal stores precision from parsed string in C#? What are the implications? During a conversation on IRC, someone pointed out the following: How/why does the `decimal` type retain precision (or, rat...
- Modified
- 2 Jan at 22:18