tagged [string]

How to do a verbatim string literal in VB.NET?

How to do a verbatim string literal in VB.NET? How do you do a string literal in VB.NET? This is achieved in C# as follows: This means that the backslashes are treated literally and not as escape char...

How to get the size of a string in Python?

How to get the size of a string in Python? For example, I get a string: I want to write it to a file. But I need to know the size of the string before writing the string to the file. What function can...

21 Jan at 19:35

What's the @ in front of a string in C#?

What's the @ in front of a string in C#? This is a .NET question for C# (or possibly VB.net), but I am trying to figure out what's the difference between the following declarations: vs. Printing out o...

27 May at 11:11

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...

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

21 Apr at 04:56

Can I escape a double quote in a verbatim string literal?

Can I escape a double quote in a verbatim string literal? In a verbatim string literal (@"foo") in C#, backslashes aren't treated as escapes, so doing \" to get a double quote doesn't work. Is there a...

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...

7 Nov at 16:0

C# Compile-Time Concatenation For String Constants

C# Compile-Time Concatenation For String Constants Does C# do any compile-time optimization for constant string concatenation? If so, how must my code by written to take advantage of this? Example: Ho...

Memory usage of concatenating strings using interpolated vs "+" operator

Memory usage of concatenating strings using interpolated vs "+" operator I see the benefit of using interpolated strings, in terms of readability: over a concatenation done this way: The author of [th...

28 Aug at 22:47

How do I extract a substring from a string until the second space is encountered?

How do I extract a substring from a string until the second space is encountered? I have a string like this: `"o1 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467"` How do I extract only `"...

3 Sep at 09:34

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 ...

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...

2 Jan at 22:18

Why is the length of this string longer than the number of characters in it?

Why is the length of this string longer than the number of characters in it? This code: outputs: Why? The only thing I could imagine is that the Chinese character is 2 bytes long and that the `.Length...

4 Feb at 09:24

What is the purpose of casting into "object" type?

What is the purpose of casting into "object" type? I have found code on a website which is as follows. Here, what is the purpose of casting into object type again since a,b,d are itself the object

Find the Number of Occurrences of a Substring in a String

Find the Number of Occurrences of a Substring in a String Why is the following algorithm not halting for me? In the code below, `str` is the string I am searching in, and `findStr` is the string occur...

15 Dec at 17:9

Options of the StringComparison Enumeration

Options of the StringComparison Enumeration I'm confused by the options of the [StringComparison Enumeration](http://msdn.microsoft.com/en-us/library/system.stringcomparison.aspx). I just want to comp...

How to compare 'μ' and 'µ' in C#

How to compare 'μ' and 'µ' in C# I fall into a surprising issue. I loaded a text file in my application and I have some logic which compares the value having µ. And I realized that even if the texts a...

How to use string interpolation and verbatim string together to create a JSON string literal?

How to use string interpolation and verbatim string together to create a JSON string literal? I'm trying to create a string literal representing an array of JSON objects so I thought of using string i...

Java generating Strings with placeholders

Java generating Strings with placeholders I'm looking for something to achieve the following: I could write it myself, but It seems to me that I saw a library once which did this, probably it was the ...

18 Dec at 15:28

Add separator to string at every N characters?

Add separator to string at every N characters? I have a string which contains binary digits. How to separate string after each 8 digit? Suppose the string is: I want to add a separator like ,(comma) a...

Compare string similarity

Compare string similarity What is the best way to compare two strings to see how similar they are? Examples: Or What I am looking for is to determine how similar the first and second string in each pa...

How can I get double quotes into a string literal?

How can I get double quotes into a string literal? I have the following output created using a `printf()` statement: but I want to put the actual quotation in double-quotes, so the output is > She sai...

7 May at 13:52

String replacement in java, similar to a velocity template

String replacement in java, similar to a velocity template Is there any `String` replacement mechanism in Java, where I can pass objects with a text, and it replaces the string as it occurs? For examp...

C#: most readable string concatenation. best practice

C#: most readable string concatenation. best practice > [How should I concatenate strings?](https://stackoverflow.com/questions/3102806/how-should-i-concatenate-strings) There are several ways to co...

23 May at 12:15

String output: format or concat in C#?

String output: format or concat in C#? Let's say that you want to output or concat strings. Which of the following styles do you prefer? - `var p = new { FirstName = "Bill", LastName = "Gates" };`- `C...

28 Oct at 17:41