title: Cross-regional decimal/double parsing
body: <p>As a matter of fact, I have multiple systems that can generate numeric data and they are stored on some web server in text files.  Some of the systems use decimal point as fraction separator, some of the systems use decimal comma as same.</p>
  
  <p>Applications (fat client, .net 2.0) can also be run on either kind of systems.</p>
  
  <p>So after some stumbling I did this: ( <a href="http://pastebin.com/vhLXABDD" rel="nofollow">http://pastebin.com/vhLXABDD</a> )</p>
  
  <pre><code>    public static bool HasDecimalComma;
      public static bool HasDecimalPeriod;
  
      public static double GetNumber(string NumberString)
      {
          if (!HasDecimalComma &amp;&amp; !HasDecimalPeriod)
          {
              string s = string.Format("{0:0.0}", 123.123);
              if (s.Contains('.'))
              {
                  HasDecimalPeriod = true;
              }
              else if (s.Contains(','))
              {
                  HasDecimalComma = true;
              }
              else
              {
                  throw new SystemException(string.Format("strange number format '{0}'", s));
              }
          }
          if (HasDecimalComma)
          {
              return double.Parse(NumberString.Replace('.', ','));
          }
          if (HasDecimalPeriod)
          {
              return double.Parse(NumberString.Replace(',', '.'));
          }
          throw new ArgumentException(string.Format("can't parse '{0}'", NumberString));
      }
  </code></pre>
  
  <p>Would you suggest any better, more elegant way?</p>
  
  <p>EDIT:</p>
  
  <p>I am sorry for not mentioning it before, and since your answers lean in that direction - I can't store generating culture with the numbers, I can only try to 'detect' it.</p>