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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:21:35+00:00 2026-06-13T19:21:35+00:00

I have code in VB.net in below: me.Index = Format(Convert.ToDouble(g.Trim()), ##.##) result : 120.00

  • 0

I have code in VB.net in below:

me.Index = Format(Convert.ToDouble(g.Trim()), "##.##")

result : 120.00

how do i same thing in C#. I don’t use format function in C#. I just want result will not place more then two value after point. i mean if i send value 120.120000 then result will be 12.12

  • 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-06-13T19:21:36+00:00Added an answer on June 13, 2026 at 7:21 pm

    It’s not clear what you mean by “I don’t use format function in C#” but of course you could use string.Format. However, using double.ToString would probably be simpler:

    Index = Convert.ToDouble(g.Trim()).ToString("0.##");
    

    (I’ve changed the leading ## to 0 to ensure that there’s always a leading digit, so you don’t get “.5” for example. Obviously if you really want the leading digits to be optional, change it to "#.##". I don’t see a benefit in using ## as a prefix though.)

    However:

    • This will use the current culture’s decimal separator; is that what you want, or do you always want to use .?
    • If the decimal representation of the number is important, you may well not want to use double at all. Are you sure you shouldn’t be using decimal?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ADO.Net code as below, that calls a stored procedure. Within the stored
I am using vb.net code. I have grid view, please see the code below:
I develop in ASP.NET MVC3, I have the code below to send the view
I have c#.net code which calls a method from another external/referenced .net assembly. This
I have ASP.Net code generating my button's HTML for me using divs to get
I have code in the top layer of my .Net web application that I'd
I have ajax code for asp.net (non-mvc) to call to a webMethod to get
I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2: smtpClient.Send(mailMsg);
I have this code : http://jsfiddle.net/VAkLn/6/ When i add a table : http://jsfiddle.net/VAkLn/7/ this
Anyone have code to set margins(top,left,right,bottom) using excel interop and vb.net. I think it

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.