Add support for named placeholders in strings #102617
Unanswered
skillmaker-dev
asked this question in
General
Replies: 2 comments 3 replies
-
This sounds like an API request, not a language request. WRT named placeholders, you may want to look for available 3rd party libraries which offer this functionality. https://www.nuget.org/packages/FormatWith comes to mind, among others. |
Beta Was this translation helpful? Give feedback.
3 replies
-
FYI: Very recently there was a quite similar suggestion: #100259. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, Can you please add support for named placeholders in strings in next versions of C#, here is what I mean by that, sometimes we define a constant string for logging, for example:
const string LogMessage = "The entity {entityNumber} is not found";
this works fine when using the logger like this:_logger.LogError(LogMessage,entityNumber)
,However, when we want to return a
NotFound
Result in controllers too, we can't use it directly, we have to use indexed placeholders and even if we usestring.Format
that won't work with named placeholders.It would be great to have a supported method like this
string.Format(LogMessage, entityNumber)
and therefore using the same defined log constant in both places.Please enlighten me in case I missed another way to do it, thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions