Click here to Skip to main content
15,888,579 members
Home / Discussions / C#
   

C#

 
QuestionInterface extensions: Guaranteed maintenance problem? Pin
jschell24-Aug-17 6:58
jschell24-Aug-17 6:58 
AnswerRe: Interface extensions: Guaranteed maintenance problem? Pin
Dave Kreskowiak24-Aug-17 9:33
mveDave Kreskowiak24-Aug-17 9:33 
AnswerRe: Interface extensions: Guaranteed maintenance problem? Pin
Bernhard Hiller24-Aug-17 21:45
Bernhard Hiller24-Aug-17 21:45 
QuestionString Format With $ Pin
Kevin Marois24-Aug-17 5:49
professionalKevin Marois24-Aug-17 5:49 
AnswerRe: String Format With $ Pin
Pete O'Hanlon24-Aug-17 6:46
mvePete O'Hanlon24-Aug-17 6:46 
GeneralRe: String Format With $ Pin
Kevin Marois24-Aug-17 6:47
professionalKevin Marois24-Aug-17 6:47 
AnswerRe: String Format With $ Pin
Bernhard Hiller24-Aug-17 21:50
Bernhard Hiller24-Aug-17 21:50 
PraiseRe: String Format With $ Pin
Richard Deeming25-Aug-17 2:04
mveRichard Deeming25-Aug-17 2:04 
True, although you could use something like this[^] to generate a strongly-typed resource class with formatter methods that get you close.

So if you had a resource string called WelcomeMessage with a value of Hello, {name}! It's {date:D} today., the tool would generate a helper method:
C#
public static string WelcomeMessage(object name, object date) 
{
    return string.Format(CultureInfo.CurrentCulture, GetString("WelcomeMessage", "name", "date"), name, date);
}

The GetString method converts the named parameter placeholders to indexed placeholder:
C#
private static string GetString(string name, params string[] formatterNames)
{
    var value = _resourceManager.GetString(name);

    Debug.Assert(value != null);

    if (formatterNames != null)
    {
        for (var i = 0; i < formatterNames.Length; i++)
        {
            value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
        }
    }

    return value;
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: String Format With $ Pin
Bernhard Hiller25-Aug-17 2:30
Bernhard Hiller25-Aug-17 2:30 
GeneralRe: String Format With $ Pin
BillWoodruff26-Aug-17 5:20
professionalBillWoodruff26-Aug-17 5:20 
GeneralRe: String Format With $ Pin
Bernhard Hiller28-Aug-17 3:25
Bernhard Hiller28-Aug-17 3:25 
QuestionEverything works fine in the Crystal-report, only the image does not display Pin
goldsoft23-Aug-17 23:37
goldsoft23-Aug-17 23:37 
QuestionANPR Pin
Member 1311476923-Aug-17 18:38
Member 1311476923-Aug-17 18:38 
AnswerRe: ANPR Pin
Pete O'Hanlon23-Aug-17 21:06
mvePete O'Hanlon23-Aug-17 21:06 
AnswerRe: ANPR Pin
Gerry Schmitz26-Aug-17 8:39
mveGerry Schmitz26-Aug-17 8:39 
QuestionHow would I go about implementing this in my code/program? Pin
Delaney Perkins22-Aug-17 22:18
Delaney Perkins22-Aug-17 22:18 
AnswerRe: How would I go about implementing this in my code/program? PinPopular
Chris Quinn22-Aug-17 23:09
Chris Quinn22-Aug-17 23:09 
AnswerRe: How would I go about implementing this in my code/program? Pin
OriginalGriff22-Aug-17 23:23
mveOriginalGriff22-Aug-17 23:23 
AnswerRe: How would I go about implementing this in my code/program? Pin
Pete O'Hanlon23-Aug-17 0:00
mvePete O'Hanlon23-Aug-17 0:00 
AnswerRe: How would I go about implementing this in my code/program? Pin
Gerry Schmitz23-Aug-17 6:38
mveGerry Schmitz23-Aug-17 6:38 
GeneralRe: How would I go about implementing this in my code/program? Pin
Eddy Vluggen23-Aug-17 7:01
professionalEddy Vluggen23-Aug-17 7:01 
GeneralRe: How would I go about implementing this in my code/program? Pin
Gerry Schmitz24-Aug-17 5:26
mveGerry Schmitz24-Aug-17 5:26 
GeneralRe: How would I go about implementing this in my code/program? Pin
Richard MacCutchan24-Aug-17 5:50
mveRichard MacCutchan24-Aug-17 5:50 
GeneralRe: How would I go about implementing this in my code/program? Pin
Gerry Schmitz26-Aug-17 8:08
mveGerry Schmitz26-Aug-17 8:08 
GeneralRe: How would I go about implementing this in my code/program? Pin
Eddy Vluggen24-Aug-17 6:38
professionalEddy Vluggen24-Aug-17 6:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.