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

  • Home
  • SEARCH
  • 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 9181069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:11:58+00:00 2026-06-17T18:11:58+00:00

Im using Visual Studio 2010. My code has a strange behavior With this code

  • 0

Im using Visual Studio 2010. My code has a strange behavior

With this code I can parse xml file.

XDocument document = XDocument.Load("http://www.studiovincent.net/list.xml");
XElement resourcesElement = document.Root.Element("resources");
XElement resourceElementVincent = (from resourceElement in resourcesElement.Elements("resource")
                                           where resourceElement.Elements("field").Single(fieldElement => fieldElement.Attribute("name").Value == "name").Value == "Vincent"
                                           select resourceElement).Single();

decimal tasso = Math.Round(decimal.Parse(resourceElementVincent.Elements("field").Single(fieldElement => fieldElement.Attribute("name").Value == "age").Value) / Convert.ToInt64(1.00E+006), 6);


string gigi = Math.Round(41 * tasso, 4).ToString();
Console.WriteLine("{0}", gigi);
Console.ReadLine();

All work correctly, until I change regional options. If I select italian:

enter image description here

This is OUTPUT: 0,0013

enter image description here

If I select United States in regional options, this is OUTPUT: 0.0000

enter image description here

I dont know how to solve this issue.

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-06-17T18:12:00+00:00Added an answer on June 17, 2026 at 6:12 pm

    decimal.Parse(string) uses the current system format; thus

    decimal.Parse(resourceElementVincent.Elements("field")
           .Single(fieldElement => fieldElement.Attribute("name").Value == "age")
           .Value)
    

    will return zero when Vincent’s age is set to 0.27 and the current culture is Italian (where the NumberDecimalSeparator is a comma).

    However, you could use the decimal.Parse(string, IFormatProvider) method instead, passing the InvariantCulture (where the NumberDecimalSeparator is a period):

    decimal.Parse(resourceElementVincent.Elements("field")
           .Single(fieldElement => fieldElement.Attribute("name").Value == "age")
           .Value, CultureInfo.InvariantCulture);
    

    MSDN documentation here.

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

Sidebar

Related Questions

I wrote this simple C code and compiled it using Visual Studio 2010, with
I compiled this code using Visual Studio 2010 ( cl.exe /W4 ) as a
I want to be able to develop code using Visual Studio 2010. I just
I have a asp.net website with c# code behind and using visual studio 2010.
The code below is in C# and I'm using Visual Studio 2010. using System;
Visual Studio 2010 C# code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using
When I generate code using T4 templates in Visual Studio 2010, I get the
I am writing Python code in Visual Studio 2010 using the excellent Python Tools
I am using an addon called Code Map in Visual Studio 2010 which makes
I am using Visual Studio 2010 in debug mode and I have "optimize code"

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.