Windows Phone Developers

Showing posts with label C# Datetime Type. Show all posts
Showing posts with label C# Datetime Type. Show all posts

Saturday, March 17, 2012

C# IsDate Function / How to check valid date using C# function

IsDate Function in .NET

If you want to check if the given entry (string) is a valid date you could have used Microsoft.VisualBasic.IsDate Function in .NET. This function is available in VB.NET. For C# you can have a similar function

Here is a hint how to create that

private void IsDateExample()
        {
            //string s1 = DateTime.Now.ToString();
            bool bSuccess = false;
            DateTime d1;
            s1 = "17-Mar-20112";
            bSuccess = DateTime.TryParse(s1, out d1);
            if (bSuccess == true)
            {
                Console.WriteLine(d1.ToString());
            
            }
            else
            {
                Console.WriteLine("Not a date at all");
            }


 

        }




The function uses DateTime.TryParse to validate the given string Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Saturday, October 11, 2008

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

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

Error Codes:

< msxsl:script implements-prefix="vbadud" language ="C#" >

< ![CDATA[

public string Defaulted(Date RetDate)

{

return "Defaulted";

}

]] >

< /msxsl:script >

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

Error Code :

< msxsl:script implements-prefix="vbadud" language ="C#" >

< ![CDATA[

public string Defaulted(datetime RetDate)

{

return "Defaulted";

}

]] >

< /msxsl:script >

Use DateTime instead of Date or datetime in C#

Corrected Code

< msxsl:script implements-prefix="vbadud" language ="C#" >

< ![CDATA[

public string Defaulted(DateTime RetDate)

{

return "Defaulted";

}

]] >

< /msxsl:script >



Name Space Date Time Error Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon