1
Answer

Money Console Application Help

Photo of kevin

kevin

15y
2.5k
1

Can i please get some help?
Question:
Write a method that takes an amount of money in the form of double and then returns the amount in the form of dollars and cents (seperatley).
Needs to be a Console Application.
Nooby at this still. Please help.

Answers (1)

0
Photo of Vulpes
NA 98.3k 1.5m 13y
Yes, if you know the format and you use (Try)ParseExact, then it doesn't matter about the culture:

      string s = "20110714";
      string f = "yyyyMMdd";
      DateTime dt;
      bool isValid = DateTime.TryParseExact(s, f, null, 0, out dt);
      if (isValid)
      {
         Console.WriteLine(dt);
      }
0
Photo of Jiteendra Sampathirao
NA 6.9k 1.5m 13y

hi,

use this:

string @DOB = DateTime.ParseExact(txtDOB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat).ToString("MM/dd/yyyy");
string @DOJ = DateTime.ParseExact(txtDOJ.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat).ToString("MM/dd/yyyy");

modify this code to you requirement....