Share via


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

Question

Friday, July 5, 2013 2:44 AM

Hi,
To this line,

                if (!DateTime.TryParseExact(tb_birth.Text, formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out birth_dt))
                ...

I've got
Error    5    The name 'CultureInfo' does not exist in the current context    C:\App11\App11\Default.aspx.cs    171    69    App11
Error    6    The name 'DateTimeStyles' does not exist in the current context    C:\App11\App11\Default.aspx.cs    171    99    App11

why?

Many Thanks & Best Regards, Hua Min

All replies (3)

Friday, July 5, 2013 3:21 AM âś…Answered | 1 vote

You're probably missing a "using namespace System.Globalization;"


Friday, July 5, 2013 3:23 AM

Its System.Globalization.CultureInfo.

Include namespace System.Globalization in your class.

See http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=vs.100).aspx


Wednesday, September 13, 2017 10:35 PM

You mean?

using System.Globalization;

Then, don't you get,

Severity   Code    Description Project File    Line    Suppression State
Error   CS0432  Alias 'CultureInfo' not found   CS-ProblemSolving_Console   DProgram.cs 74  Active