Write code for palindrome?

Answer Posted / sayan

Private Sub btnAnswer_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnevaluate.Click
Dim Input As String

If IsPalindrome(Input) Then
txtAnswer.Text = "True"
Else
txtAnswer.Text = "False"

End If



End Sub
Function IsPalindrome(ByVal Input As String) As Boolean

Dim Front As Integer
Dim Back As Integer
Dim Middle As Integer
Dim nPalindrome As Boolean

IsPalindrome = False
nPalindrome = True


Back = Input
Middle = Back / 2
Front = 1
If (Back < 1) Then
Exit Function
End If

Do While (Front <> Back And Front <= Middle)
If (Mid(Input, Front, 1) <> Mid(Input, Back, 1)) Then
nPalindrome = False
Exit Do
End If
Back = Back - 1
Front = Front + 1
Loop
IsPalindrome = nPalindrome
Exit Function

End Function
End Class

Is This Answer Correct ?    7 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is serializable in c#?

492


Explain how many types of exception handlers are there in .net?

466


Why is c# better than java?

499


How do you declare an arraylist?

490


Can we instantiate abstract class in c#?

473






What are the Types of compatabilities and explain them

516


What is difference between comparable and comparator?

460


What is transparent caching with aop ?

622


In a memory when you Box and Unbox a value-type what happens?

540


Define parsing?

501


Is c# good for beginners?

471


Which class comes after the SortedList class?

566


How does a while loop work?

472


Where value types are stored in c#?

500


What is lazy loading c#?

498