Linked Questions
25 questions linked to/from Named string formatting in C#
3 votes
0 answers
89 views
Use of named identifiers in String.Format [duplicate]
Possible Duplicate: Named string formatting in C# Has anyone found a way to use named identifiers in the String.Format command? Having that kind of functionality would be helpful for "old" folks ...
478 votes
150 answers
135k views
What are your favorite extension methods for C#? (codeplex.com/extensionoverflow)
Let's make a list of answers where you post your excellent and favorite extension methods. The requirement is that the full code must be posted and a example and an explanation on how to use it. ...
185 votes
32 answers
103k views
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" }; Console.WriteLine("{0} {1}", p.FirstName, p....
183 votes
12 answers
592k views
How to insert newline in string literal?
In .NET I can provide both \r or \n string literals, but there is a way to insert something like "new line" special character like Environment.NewLine static property?
141 votes
9 answers
103k views
Is there a "String.Format" that can accept named input parameters instead of index placeholders? [duplicate]
This is what I know str = String.Format("Her name is {0} and she's {1} years old", "Lisa", "10"); But I want something like str = String("Her name is @name and she's @age years old"); str....
30 votes
5 answers
37k views
Using FluentValidation's WithMessage method with a list of named parameters
I am using FluentValidation and I want to format a message with some of the object's properties value. The problem is I have very little experience with expressions and delegates in C#. ...
14 votes
12 answers
10k views
Is there a better way to count string format placeholders in a string in C#?
I have a template string and an array of parameters that come from different sources but need to be matched up to create a new "filled-in" string: string templateString = GetTemplate(); // e.g. "Mr ...
19 votes
7 answers
2k views
String Format descriptive text
Is it possible to add some descriptive text to a string format specifier? Example: string.Format ("{0:ForeName} is not at home", person.ForeName); In the example ForeName is added as description. ...
11 votes
6 answers
18k views
Replace {x} tokens in strings
We have a template URL like: http://api.example.com/sale?auth_user=xxxxx&auth_pass=xxxxx&networkid={networkid}&category=b2c&country=IT&pageid={pageid}&programid=133&saleid=...
14 votes
4 answers
14k views
Is it possible to pass interpolated strings as parameter to a method?
I have started to use Interpolated Strings (new feature of C# 6) and it is really useful and gracefully. But according to my needs I have to pass format of string to a method as a parameter. Something ...
9 votes
4 answers
2k views
C#: can labels be used instead of numbers with String.Format?
Refering to this link http://msdn.microsoft.com/en-us/library/b1csw23d.aspx it seems that it is not possible with the String.Format method to use labels instead of indices in the format string ...
3 votes
4 answers
3k views
Loading and accessing template variables inside text file
we have a bunch of text templates that are embedded resources in our visual studio solution. I'm using a simple method like this to load them: public string getTemplate() { var ...
1 vote
2 answers
1k views
String.Format use a string instead of an integer [duplicate]
When using String.Format, you use {0}, {1}, {2}, etc. to reference the variables to place in the string, for example: string s = String.Format("{0} {1}", "Like", "this."); Is there any way that I can ...
0 votes
1 answer
2k views
XML / HTML Email Template for Error Reporting
I want to create a template with XML or HTML with placeholders for exception reporting variables to be swapped in at runtime when an exception occurs. I like what I've got so far with the template, ...
0 votes
3 answers
2k views
Replace tokens in an aspx page on load
I have an aspx page that contains regular html, some uicomponents, and multiple tokens of the form {tokenname} . When the page loads, I want to parse the page content and replace these tokens with ...