Problem with VS2005 and not 2003

I just upgraded to VS2005 and in one section of an app ive been working on i get a problem.

Code:


    Function GetLegalEmail(ByRef anEmail As String) As String
        'Try to extract the legal part of an email e.g. from reply address and return nothing if there is a problem.
        Dim eMailParts(2) As String
        Dim leftPart As String = ""
        Dim rightPart As String = ""
        Try
            GetLegalEmail = ""
            eMailParts = anEmail.Split("@", 2)
            leftPart = getLegalFromRight(eMailParts(0))
            If leftPart = "" Then Exit Function
            rightPart = getLegalFromLeft(eMailParts(1))
            If rightPart = "" Then Exit Function
            If hasMisplacedDot(leftPart) Then Exit Function
            If hasMisplacedDot(rightPart) Then Exit Function
            GetLegalEmail = leftPart & "@" & rightPart
        Catch ex As Exception
            CoutErr(vbNewLine & "GetLegalEmail: " & ex.Message)
        End Try

    End Function


The error is underlined at eMailParts = anEmail.Split("@", 2)

The error is:

Overload resolution failed because no accessible 'Split' can be called without a narrowing conversion:
    'Public Function Split(separator() As Char, options As System.StringSplitOptions) As String()': Argument matching parameter 'separator' narrows from 'String' to '1-dimensional array of Char'.
    'Public Function Split(separator() As Char, options As System.StringSplitOptions) As String()': Argument matching parameter 'options' narrows from 'Integer' to 'System.StringSplitOptions'.
    'Public Function Split(separator() As Char, count As Integer) As String()': Argument matching parameter 'separator' narrows from 'String' to '1-dimensional array of Char'.


any ideas?
LVL 1
bryanfordAsked:
Who is Participating?
 
Carl TawnSystems and Integration DeveloperCommented:
Ok, scratch that. Try:

    eMailParts = anEmail.Split("@".ToCharArray(), 2)
0
 
Carl TawnSystems and Integration DeveloperCommented:
Try changing it to:

    eMailParts = anEmail.Split('@', 2)
0
 
bryanfordAuthor Commented:
That got rid of the error however now its underlined only the open bracket and says "Expression Expected"
0
 
bryanfordAuthor Commented:
that seems to have done the job. Thanks :)

Do you know why this would work in 2003 and not 2005?
0
 
Carl TawnSystems and Integration DeveloperCommented:
Not sure. I can only think that it is a change in the way that strings are stored.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.