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 6815625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:49:47+00:00 2026-05-26T20:49:47+00:00

If the title isn’t accurate enough, please feel free to change it to something

  • 0

If the title isn’t accurate enough, please feel free to change it to something more well named.

So i have a public static void:

public static void outputDictionaryContents(Dictionary<string, int> list)
{
    foreach (KeyValuePair<string, int> pair in list)
    {
        Console.WriteLine("{0}, {1}", pair.Key, pair.Value);
    }
}

and I am wanting to write out what it produce on a html file, it will output it fine on command prompt via:

outputDictionaryContents(sortedDict);

but when it comes to outputting it in my html with the following code:

tw.WriteLine("<td width\"480\">{0}</td>", outputDictionaryContents(sortedDict));

but I keep getting the following error:

The best overloaded method match for 'System.IO.TextWriter.WriteLine(string, object)' has some invalid arguments
Argument '#2' cannon convert 'void' expression to type 'object'

So i’m not completely sure in what the best way is to fix this problem.

Thanks in advance.

  • 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-26T20:49:47+00:00Added an answer on May 26, 2026 at 8:49 pm

    Your method doesn’t return a string – it writes to the console.

    You could change it to return a string directly:

    public static string GetDictionaryContents(Dictionary<string, int> list)
        {
            StringBuilder builder = new StringBuilder();
            foreach (KeyValuePair<string, int> pair in list)
            {
                builder.AppendFormat("{0}, {1}{2}", pair.Key, pair.Value, Environment.NewLine);
            }
    
            return builder.ToString();
        }
    

    That being said, if you’re going to write this into an HTML output, you probably need to rethink what you want to write. Writing newline separated info directly into a table cell is not going to format correctly…

    You are more likely going to, at a minimum, want some additional formatting, or provide a separate terminator (such as a <br /> instead of a newline)…

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

Sidebar

Related Questions

Sorry the title isn't more help. I have a database of media-file URLs that
Sorry the title isn't more specific. I have some minor problems with a jquery
The title isn't very descriptive but I couldn't find a better one. Feel free
Sorry if the title isn't really related to my question well enough, I wasn't
Sorry if the title isn't clear enough, but in Javascript you can do this
If the title isn't clear enough, here's a procedural way of approaching the problem:
The title isn't clear as I couldn't think of one but, I have an
My question title isn't clear, sorry. I tried ;) I have a binary string
Apologies if the Topic title isn't accurate, I didn't really know how to express
Sorry the title isn't clear enough. I don't know how to express it, but

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.