What's Here?
- Members: 117,574
- Replies: 431,934
- Topics: 66,689
- Snippets: 2,395
- Tutorials: 631
- Total Online: 2,072
- Members: 60
- Guests: 2,012
Who's Online?
|
Welcome to Dream.In.Code |
|
Getting C# Help is Easy!
Join 117,574 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 2,072 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
|
Returns true if a string is palindromic.
|
Submitted By: RodgerB
|
|
|
Rating:
|
|
Views: 412 |
Language: C#
|
|
Last Modified: May 11, 2008 |
Instructions:
1) Copy and paste the function into a class.
2) Read the example on how to call the function. |
Snippet
/// <summary>
/// Check to see if a string is palindromic.
/// </summary>
/// <param name="strToCheck">The string to check</param>
/// <returns>True if the string is palindromic, false otherwise.</returns>
public static bool isPalindromic(string strToCheck)
{
for (int i = 0; i < strToCheck.Length / 2; i++)
if (!(strToCheck[i] == strToCheck[strToCheck.Length - 1 - i])) return false;
return true;
}
// Example Usage
MessageBox.Show(isPalindromic("racecar").ToString());
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|