C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Get ZodiacSign


Posted Date: 03 Apr 2008    Resource Type: Code Snippets    Category: Date & Time

Posted By: Raju.M       Member Level: Gold
Rating:     Points: 5



The code sample is a simple function in C# that uses a series of if-else statements to return the Zodiac Sign given the Date of Birth.

The code is also a good example to illustrate the members and uses of a DateTime object in .NET.



public string ZodiacSign(DateTime DateOfBirth)
{
string returnString = string.Empty;
string[] dateAndMonth = DateOfBirth.ToLongDateString().Split(new char[] { ',' });
string[] ckhString = dateAndMonth[1].ToString().Split(new char[] { ' ' });
if (ckhString[1].ToString() == "March")
{
if (Convert.ToInt32(ckhString[2]) <= 20)
{
returnString = "Pisces";
}
else
{
returnString = "Aries";
}
}
else if (ckhString[1].ToString() == "April")
{
if (Convert.ToInt32(ckhString[2]) <= 19)
{
returnString = "Aries";
}
else
{
returnString = "Taurus";
}
}
else if (ckhString[1].ToString() == "May")
{
if (Convert.ToInt32(ckhString[2]) <= 20)
{
returnString = "Taurus";
}
else
{
returnString = "Gemini";
}
}
else if (ckhString[1].ToString() == "June")
{
if (Convert.ToInt32(ckhString[2]) <= 20)
{
returnString = "Gemini";
}
else
{
returnString = "Cancer";
}
}
else if (ckhString[1].ToString() == "July")
{
if (Convert.ToInt32(ckhString[2]) <= 22)
{
returnString = "Cancer";
}
else
{
returnString = "Leo";
}
}
else if (ckhString[1].ToString() == "August")
{
if (Convert.ToInt32(ckhString[2]) <= 22)
{
returnString = "Leo";
}
else
{
returnString = "Virgo";
}
}
else if (ckhString[1].ToString() == "September")
{
if (Convert.ToInt32(ckhString[2]) <= 22)
{
returnString = "Virgo";
}
else
{
returnString = "Libra";
}
}
else if (ckhString[1].ToString() == "October")
{
if (Convert.ToInt32(ckhString[2]) <= 22)
{
returnString = "Libra";
}
else
{
returnString = "Scorpio";
}
}
else if (ckhString[1].ToString() == "November")
{
if (Convert.ToInt32(ckhString[2]) <= 21)
{
returnString = "Scorpio";
}
else
{
returnString = "Sagittarius";
}
}
else if (ckhString[1].ToString() == "December")
{
if (Convert.ToInt32(ckhString[2]) <= 21)
{
returnString = "Sagittarius";
}
else
{
returnString = "Capricorn";
}
}
else if (ckhString[1].ToString() == "January")
{
if (Convert.ToInt32(ckhString[2]) <= 19)
{
returnString = "Capricorn";
}
else
{
returnString = "Aquarius";
}
}
else if (ckhString[1].ToString() == "February")
{
if (Convert.ToInt32(ckhString[2]) <= 18)
{
returnString = "Aquarius";
}
else
{
returnString = "Pisces";
}
}
return returnString;
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using DateTime object  .  Obtain Zodiac sign from Date of birth  .  Get Zodiac sign from Date of Birth  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Week of the Year
Previous Resource: Different types of Date Formats
Return to Discussion Resource Index
Post New Resource
Category: Date & Time


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it outsourcing

Contact Us    Privacy Policy    Terms Of Use