Linked Questions

3 votes
0 answers
89 views

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 ...
Andy Evans's user avatar
  • 7,204
478 votes
150 answers
135k views

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

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

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?
Captain Comic's user avatar
141 votes
9 answers
103k views

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....
Polamin Singhasuwich's user avatar
30 votes
5 answers
37k views

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#. ...
Jason's user avatar
  • 4,715
14 votes
12 answers
10k views

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 ...
Damovisa's user avatar
  • 19.4k
19 votes
7 answers
2k views

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. ...
thumbmunkeys's user avatar
  • 20.8k
11 votes
6 answers
18k views

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=...
eLs's user avatar
  • 213
14 votes
4 answers
14k views

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 ...
RredCat's user avatar
  • 5,441
9 votes
4 answers
2k views

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 ...
user avatar
3 votes
4 answers
3k views

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 ...
SkyeBoniwell's user avatar
  • 7,216
1 vote
2 answers
1k views

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 ...
Liam Flaherty's user avatar
0 votes
1 answer
2k views

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, ...
Chiramisu's user avatar
  • 4,736
0 votes
3 answers
2k views

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 ...
RYFN's user avatar
  • 3,090

15 30 50 per page