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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:01:53+00:00 2026-05-13T02:01:53+00:00

Hi I have searched Google my best but couldn’t recover from these errors: The

  • 0

Hi I have searched Google my best but couldn’t recover from these errors:

The name 'DateTimeStyles' does not exist in the current context

…

The type or namespace name 'CultureInfo' could not be found (are you missing a using directive or an assembly reference?)

.. can you please help me out with, if something I have missed .. Here is my code ..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Security.Permissions;
using System.Threading;

namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] formats = {"M/d/yyyy h:mm:ss tt", "M/d/yyyy h:mm tt", 
                   "MM/dd/yyyy hh:mm:ss", "M/d/yyyy h:mm:ss", 
                   "M/d/yyyy hh:mm tt", "M/d/yyyy hh tt", 
                   "M/d/yyyy h:mm", "M/d/yyyy h:mm", 
                   "MM/dd/yyyy hh:mm", "M/dd/yyyy hh:mm"};
            string[] dateStrings = {"5/1/2009 6:32 PM", "05/01/2009 6:32:05 PM", 
                        "5/1/2009 6:32:00", "05/01/2009 06:32", 
                        "05/01/2009 06:32:00 PM", "05/01/2009 06:32:00"};
            DateTime dateValue;

            foreach (string dateString in dateStrings)
            {
                if (DateTime.TryParseExact(dateString, formats,
                                           new CultureInfo("en-US"),
                                           DateTimeStyles.None,
                                           out dateValue))
                    Console.WriteLine("Converted '{0}' to {1}.", dateString, dateValue);
                else
                    Console.WriteLine("Unable to convert '{0}' to a date.", dateString);
            }
        }
    }
}

I am using visual studio 2005.

  • 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-05-13T02:01:53+00:00Added an answer on May 13, 2026 at 2:01 am

    Looks like your using statements are OK. There must be a reference missing. Both types mentioned in the error msg live in mscorlib.dll.

    I believe that the C# compiler always references mscorlib, unless you ask it not to, using the /nostdlib command line option.

    How do you compile your program? If using Visual Studio, check your project’s settings for an option ‘do not use stdlib’ or something like that (another answer explains where to find the option). If using the command line compiler, make sure you are not passing the /nostdlib option.

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

Sidebar

Related Questions

I've searched google and SO for a solution to this problem but have not
I've searched the iPhone documentation and on google but have not found any information
I have searched google up and down but I can not find nearly any
I have searched this topic on google a bit and seen some best practices.
I have searched a bit on google, but didn't really found an answer to
I have searched through google and SO for possible answers to this question, but
I have searched here and on Google, but as an inexperienced Javascript hack I'm
I searched a lot over Google, but cant find a valid solution for best
I have searched alot on google and in here to find the best featured
I have searched google and exhausted a fair bit of my time trying to

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.