Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Smarter on March 24, 2007, 03:27 PM

Title: [C#] Problem...
Post by: Smarter on March 24, 2007, 03:27 PM

Public Function GetString(S As String) As String: GetString = Mid(S, InStr(1, S, Chr(34)) + 1, Len(S) - (InStr(1, S, Chr(34)) + 1)): End Function


This code takes the string contained inside quotes("), and then returns it without them, this is used for things like:
|INFO "Blah has banned blah2 (blah)"

Where, if you had split the string by space, it wouldn't give you the quoted text, however I'm not sure how to reproduce this function in C#, I thought of doing a like replace, but then I'd have to use a switch, and parse it for the first two splits, and ugh, i'm just confused.
Title: Re: [C#] Problem...
Post by: l)ragon on March 25, 2007, 07:48 AM
    Public Function GetString(ByVal S As String) As String
        Return S.Substring(S.IndexOf(""""), S.IndexOf("""", S.IndexOf("""") + 1))
    End Function


I'm a bit tired atm but this should help you figure out substring abit.