Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6619691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:00:07+00:00 2026-05-25T21:00:07+00:00

How to replace a method signature to accept parameterized strings without using param keywords.

  • 0

How to replace a method signature to accept parameterized strings without using param keywords. I have seen this functionality in Console.WriteLine().
e.g.

public void LogErrors(string message, params string[] parameters) { }

Scenario:

I have an error login function called

LogErrors(string message)
{
    //some code to log errors
}

I am calling this function at different locations in the program in a way that the error messages are hardcoded. e.g.:

LogError("Line number " + lineNumber + " has some invalid text");

I am going to move these error messages to a resource file since I might change the language (localization) of the program later. In that case, how can I program to accept curly bracket bases parameterized strings? e.g.:

LogError("Line number {0} has some invalid text", lineNumber)

will be written as:

LogError(Resources.Error1000, lineNumber) 

where Error1000 will be “Line number {0} has some invalid text”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:00:08+00:00Added an answer on May 25, 2026 at 9:00 pm

    You probably want two methods:

    public void LogErrors(string message, params string[] parameters)
    {
        LogErrors(string.Format(message, parameters));
    }
    
    public void LogErrors(string message)
    {
        // Use methods with *no* formatting
    }
    

    I wouldn’t just use a single method with the params, as then it’ll try to apply formatting even if you don’t have any parameters, which can make things harder when you want to use “{” and “}” within a simple message without any parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried converting the double value into a string and using the Replace() method
How can I do this with the JS replace() method: Make \n\n change to
I'm looking for a way to write a search and replace method using W3C
I know we have a replace method to replace a substring within a string
I am selecting text using SelectText method in my string. I want to replace
I was just playing with the native replace method for strings in javascript. Is
I have a Pl/Sql procedure signature that look like this foo(param1 IN type1, param2
This is my replace method in java but unble to replace for following. It
I have a class which contains this method /** * Uses the native RegExp
It seems the .NET Regex.Replace method automatically replaces all matching occurrences. I could provide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.