2

In my application I print messages, some are Debug and some need to fire up as popup window.
I must use Localization as described in: How to use localization in C#
My question is, if my output is based on data member, how can i send it to the Value and use it in the resx file ?
My output log is:

string.Format("Operation Id = {0} has failed", opId);

But when i wish to add it as localized, I cant put in Value (in my output_messages.resx) the data member opId.

Community
  • 1
  • 1
ilansch
  • 4,784
  • 7
  • 47
  • 96
  • _But when i wish to add it as localized, I cant put in Value (in my output_messages.resx) the data member opId._ How come? Can you tell the error why you can't put it in the variable? – aiapatag Jun 03 '13 at 09:59
  • when using visual studio .resx editor for strings, It is not clear, that i can use {0} in it. I didnt know its possible. – ilansch Jun 03 '13 at 10:49

1 Answers1

5

You store the format string, i.e. the resx might contain:

Operation Id = {0} has failed

(against some key)

Then you can use:

string.Format(yourResources.WhateverNameYouUsed, opId);
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900