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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:23:24+00:00 2026-05-23T00:23:24+00:00

I output data from a process to a csv. I store intermediate results in

  • 0

I output data from a process to a csv. I store intermediate results in a data class, which also has methods to output the data to a string so it can be written to a file.

Class DataClass {

    // the actual data
    public double Value1 { get; set; } 
    public double Value2 { get; set; } 
    public double Value3 { get; set; } 

    // return headers for this dataclass (called once)
    public static string Headers { get { return "Value1\tValue2\tValue3"; } }

    // no decimals needed (keep filesize smaller, numbers are millions and up)
    static NumberFormatInfo nfi = new NumberFormatInfo() { NumberDecimalDigits = 0 }; 

    // this returns a string with the values for the dataclass (called for each row)
    public string ValuesString {
        get {
            // ** I would expect the numbers to have NO decimals because of nfi **
            return string.Format(nfi, "{0}\t{1}\t{2}",
                Value1,
                Value2,
                Value3,
            );
        }
    }
}

Here i write to the file:

// headers
swResultFile.WriteLine("Group\t" + GroupResult.Headers);

// values
foreach (var r in GroupResults) swResultFile.WriteLine(r.Key + "\t" + r.Value.ValuesString);

But the output file still has all the decimals:

Group  Value1   Value2  Value3
1   176983.222718191    278477.364780645    462811.208871335
2   11262339.27 16383.9680721473    118430.334721429

Does anyone know why it’s ignoring the NumberFormatInfo?

When I check it in the debugger it looks just fine.

Thanks,

Gert-Jan

  • 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-23T00:23:25+00:00Added an answer on May 23, 2026 at 12:23 am

    You have to use the N format specifier for Format to use the NumberFormatInfo. Try this

     return string.Format(nfi, "{0:N}\t{1:N}\t{2:N}",
                Value1,
                Value2,
                Value3,
            );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a process which extracts data from 6 csv-style files and two poorly
I wrote a python script to process some data from CSV files. The script
I want to generate some formatted output of data retrieved from an MS-Access database
I'm trying to read data from a.csv file to ouput it on a webpage
I have a DataSet consisting of XML data, I can easily output this to
I am using the following code to output data from a number of tables
Is there a way to use these operators to input and output binary data?
I am writing the data to the output browser using Response.write(some byte arrary) Response.ContentType
I'm trying to stream binary data to the standard output in .NET. However you
I have noticed that cURL in PHP returns different data when told to output

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.