How to use placeholders in a string resource programmatically

Apptacular Apps 386 Reputation points
2020-06-10T15:05:20.74+00:00

What's the correct way to access a string resource and use its placeholders? The method I tried didn't work for me.

Name: MyPlaceholders

Value: {0} ({1})

What I want to put in each placeholder: Hello (World)

C#

resourceLoader.GetString("MyPlaceholders")

Current result

{0} ({1})
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Matt Lacey 791 Reputation points
    2020-06-10T15:09:18.3+00:00

    As the resource holds the format, you need to populate it.

    string.Format(resourceLoader.GetString("MyPlaceholders"), "Hello", "World")

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.