Getting good answers on StackOverflow – part 10 of n

Tip #10 – What, not how

When posting a question, don’t say how (or how not) you want people to answer it (for example, “I don’t want to hear about xxx”, “Only solutions in yyy”), but explain what you are attempting to achieve. This gives context to your question and better answers will result.

By telling people how you want to do things, you are limiting the answers and possibly offending them.

Tip #1 – Ask a question

Tip #2 – Be polite

Tip #3 – Ask one question

Tip #4 – Descriptive title

Tip #5 – Write in English

Tip #6 – Pertinent code samples

Tip #7 – Stay on topic

Tip #8 – Do some research

Tip #9 – Stay engaged

Share:
error

So you need to format some money

When formatting a currency for display, always use a CultureInfo object when outputting in order to get the correct formatting – different places will have a different thousands separator, decimal separator and more.

In many cases, you can get the CultureInfo from the UI thread and in a web application you could guess which one is the correct one, by parsing out the user agent header.

If you always want the exact same output, you do not have to specify a format string, simply use CultureInfo.InvariantCulture, this is a dummy culture and does not correspond to any country/region. The different settings are similar to “en-US”.

This example will output the format for the Swedish culture.

decimal value = -16325.62m;
Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("sv-SE")));

This example will output the format for the InvariantCulture.

decimal value = -16325.62m;
Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));

Here is a list of culture names.

Share:
error

Getting good answers on StackOverflow – part 9 of n

Tip #9 – Stay engaged

Don’t fire and forget – that is, keep going back to your question, read the comments and answer and respond to them. If you engage with the people that respond to your question, chances are good that you will get the answer you are looking for.

Tip #1 – Ask a question

Tip #2 – Be polite

Tip #3 – Ask one question

Tip #4 – Descriptive title

Tip #5 – Write in English

Tip #6 – Pertinent code samples

Tip #7 – Stay on topic

Tip #8 – Do some research

Share:
error

Getting good answers on StackOverflow – part 6 of n

Tip #6 – Pertinent code samples

Post code samples that show the issue, this will help others understand the issues better than paragraphs full of description.

Do not post pages and pages of code – no one will want to read through that, so limit yourself to code that is directly relevant to the question.

Tip #1 – Ask a question

Tip #2 – Be polite

Tip #3 – Ask one question

Tip #4 – Descriptive title

Tip #5 – Write in English

Share:
error

Getting good answers on StackOverflow – part 5 of n

Tip #5 – Write in English

The language of StackOverflow is English.

Do not post in another language, as your question will get closed promptly.

Check your spelling and grammar, and do not use text speak (type “you” instead of “u”, “please” instead of “plz”). This show that you care to be understood, so others will be more likely to respond.

Tip #1 – Ask a question

Tip #2 – Be polite

Tip #3 – Ask one question

Tip #4 – Descriptive title

Share:
error