question

ApptacularApps-8305 avatar image
ApptacularApps-8305 asked ·

How to use placeholders in a string resource programmatically

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})
windows-uwp-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

mrlacey avatar image
mrlacey answered ·

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

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

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.