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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:36:42+00:00 2026-06-04T23:36:42+00:00

Maybe it’s a n00b question but I’ve looked at the .net/C# MSDN Library and

  • 0

Maybe it’s a n00b question but I’ve looked at the .net/C# MSDN Library and on this site and have yet to come to a clear answer… say I had For Ex:
(this is not exactly the problem, as I’m not creating the string but reading them out of a DB. But serves to illustrate what I’m working with…)

string dob = "01/02/1990";
dob.ToString("MM/dd/YY"); //however, I can't do this. compiler gives me an error...

likely because it is already a string? How then could I get the string into the format that I want using specifiers, when it’s already a string?
I know I could convert it to something else (a DateTime for Ex) and convert back to string using the ToString()…but this seems counter productive… to me at least

I also have several other “kinds” of string variables I’m trying to display into specific formats whilst saving them to a Idictionary for printing into a pdf’s fields.
For ex:

d["amount"] = prod.sales.StringAmount; //(here StringSmount holds say 50000 (gotten from a DB), which I want to display as "50,000")

However, I also can’t do prod.sales.StringAmount.ToString(“N”, CultureInfo.CurrentUICulture); cuz it’s already a string! Is there an easy way to do this

or need I mess with String Buffers or the StringBuilder class??
thanks!

  • 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-04T23:36:44+00:00Added an answer on June 4, 2026 at 11:36 pm

    You can do something like this:

    DateTime dob = DateTime.Parse("01/02/1990"); 
    

    and then

    dob.ToString("MM/dd/YY");
    

    will work.

    Note that DateTime.Parse() has various options for the possible date-time formats to accept, and that there is also a TryParse() version that returns false if the string is not a valid date – instead than throwing an exception. There are also DateTime.ParseExact() and DateTime.TryParseExact() variations.

    Use the same approach for other data types beside date-times: first convert the input string in the correct data type (integer, float etc) – using the various Parse() or TryParse() methods, and then format the result of this conversion.

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

Sidebar

Related Questions

Maybe this question is kind of silly but I have no clue how to
Maybe I just don't know .NET well enough yet, but I have yet to
Maybe this is a dumb question, but I have the following behavior in Visual
Maybe this is a poor question, but, I can't find a tutorial or even
Maybe this is a simple question, but I didn't find answer in web. I
Maybe I am out of my mind right now, but I have a question
Maybe there is a similar question to this, but I couldn't find a one.
Maybe this is very basic, but I am all confused. I have a simple
maybe this is an old question but i'm trying as a personal experiment to
Maybe I am being stupid, but this isn't making sense to me... I have

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.