d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Could Use Some Vb Help
Prev123
Add Reply New Topic New Poll
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
May 8 2015 05:25pm
Quote (carteblanche @ May 8 2015 06:35am)
one tiny problem. he's not checking for a palindrome of a string. he's checking if you reverse the order of words of a sentence.


I thought I saw palindrome somewhere....trigger happy

my mistake ~_~
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
May 8 2015 05:51pm
Code
Sub Main()
Dim myString As New String("You can cage a swallow, can't you, but you can't swallow a cage, can you")
Dim myStrings As New List(Of String)()

myStrings = myString.Replace(",", "").Split(" ").ToList()

For i As Integer = 0 To myStrings.Count - 1
If String.Equals(myStrings.Item(i), myStrings.Item(myStrings.Count - 1 - i), StringComparison.OrdinalIgnoreCase) Then
Else
Console.WriteLine("Not a Palindrome")
Console.ReadLine()
Return
End If
Next
Console.WriteLine("Palindrome!")
Console.ReadLine()
End Sub


redundancy is redundant

ignore it if you see it

edit: got rid of it

now with less lists

This post was edited by Eep on May 8 2015 05:56pm
Go Back To Programming & Development Topic List
Prev123
Add Reply New Topic New Poll