Login Register






[VB.NET/C#] Text Flipping Example - LINQ filter_list
Author
Message
[VB.NET/C#] Text Flipping Example - LINQ #1
Code:
Private Shared Function TextFlip(InputString As String) As String Dim X() As Char = "¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ".ToCharArray, _ V As String = "?\.,/_!zyxwvutsrqponmlkjihgfedcba" Return StrReverse(New String((From Obj As Char In InputString.ToCharArray() Select If(V.IndexOf(Obj) <> -1, X(V.IndexOf(Obj)), Obj)).ToArray)) End Function

Code:
private string TextFlip(string InputString) { char[] X = @"¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ".ToCharArray(); string V = @"?\.,/_!zyxwvutsrqponmlkjihgfedcba"; return new string((from char obj in InputString.ToCharArray() select (V.IndexOf(obj) != -1) ? X[V.IndexOf(obj)] : obj).Reverse().ToArray()); }

I seen someone post an extensive code on this somewhere else, and decided to simplify it.

Here was the extended and convoluted version:
Spoiler:
Code:
Public Class Form1 Dim X As String = "¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ", _ V As String = "?\.,/_!zyxwvutsrqponmlkjihgfedcba" Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim str As String, Newstr As String = Nothing str = TextBox1.Text For Each StrText As String In str Select Case True Case StrText = "b" StrText = "p" Case StrText = "p" StrText = "b" Case StrText = "q" StrText = "d" Case StrText = "d" StrText = "q" Case StrText = "u" StrText = "n" Case True For I = 0 To X.Length - 1 StrText = StrText.Replace(V.ElementAt(I), _ X.ElementAt(I)) Next End Select Newstr &= StrText Next TextBox2.Text = Newstr TextBox2.Text = StrReverse(TextBox2.Text) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

[VB.NET/C#] Text Flipping Example - LINQ #2
Code:
Private Shared Function TextFlip(InputString As String) As String Dim X() As Char = "¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ".ToCharArray, _ V As String = "?\.,/_!zyxwvutsrqponmlkjihgfedcba" Return StrReverse(New String((From Obj As Char In InputString.ToCharArray() Select If(V.IndexOf(Obj) <> -1, X(V.IndexOf(Obj)), Obj)).ToArray)) End Function

Code:
private string TextFlip(string InputString) { char[] X = @"¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ".ToCharArray(); string V = @"?\.,/_!zyxwvutsrqponmlkjihgfedcba"; return new string((from char obj in InputString.ToCharArray() select (V.IndexOf(obj) != -1) ? X[V.IndexOf(obj)] : obj).Reverse().ToArray()); }

I seen someone post an extensive code on this somewhere else, and decided to simplify it.

Here was the extended and convoluted version:
Spoiler:
Code:
Public Class Form1 Dim X As String = "¿/˙'\‾¡zʎxʍʌnʇsɹbdouɯlʞɾıɥƃɟǝpɔqɐ", _ V As String = "?\.,/_!zyxwvutsrqponmlkjihgfedcba" Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim str As String, Newstr As String = Nothing str = TextBox1.Text For Each StrText As String In str Select Case True Case StrText = "b" StrText = "p" Case StrText = "p" StrText = "b" Case StrText = "q" StrText = "d" Case StrText = "d" StrText = "q" Case StrText = "u" StrText = "n" Case True For I = 0 To X.Length - 1 StrText = StrText.Replace(V.ElementAt(I), _ X.ElementAt(I)) Next End Select Newstr &= StrText Next TextBox2.Text = Newstr TextBox2.Text = StrReverse(TextBox2.Text) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: [VB.NET/C#] Text Flipping Example - LINQ #3
Thanks for sharing. I've never considered doing this before.
#steez

Reply

RE: [VB.NET/C#] Text Flipping Example - LINQ #4
Thanks for sharing. I've never considered doing this before.
#steez

Reply

RE: [VB.NET/C#] Text Flipping Example - LINQ #5
Finally... My first reply where ever i've posted this lol. Wow.

Thanks Smile
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: [VB.NET/C#] Text Flipping Example - LINQ #6
Finally... My first reply where ever i've posted this lol. Wow.

Thanks Smile
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: [VB.NET/C#] Text Flipping Example - LINQ #7
(04-15-2012, 06:46 AM)PhazeShift Wrote: Finally... My first reply where ever i've posted this lol. Wow.

Thanks Smile

lol no problem, the same thing happens to me all the time. Basically, if your code isn't for a keylogger, rat, or any other type of malware you won't get many replies. Sad
#steez

Reply

RE: [VB.NET/C#] Text Flipping Example - LINQ #8
(04-15-2012, 06:46 AM)PhazeShift Wrote: Finally... My first reply where ever i've posted this lol. Wow.

Thanks Smile

lol no problem, the same thing happens to me all the time. Basically, if your code isn't for a keylogger, rat, or any other type of malware you won't get many replies. Sad
#steez

Reply