Hi Jon,
I'm converting the Web Log Analyzer Starter Kit from VB to C#. In the
following procedure, I'm stuck on the line to convert the AscW logic below:
Public Function Parse(ByVal logFileName As String) As List(Of LogFileEntry)
' A collection representing all valid entries in the log file.
Dim logFileEntries As New List(Of LogFileEntry)
' Remember the name of the log file. This is needed later to
generate error messages.
m_logFileName = logFileName
' Read the contents of the file line by line and parse each line.
Using reader As New StreamReader(logFileName)
Do
Dim line As String = reader.ReadLine()
' If there are no more lines then exit the loop.
If (line Is Nothing) Then Exit Do
' If the first character is a 0 byte then exit the loop. This
may happen if IIS
' is still writing to the log file.
If (line.Length 0) AndAlso (AscW(line.Chars(0)) = 0) Then
Exit Do
' If the first character is a # then this is a directive
otherwise it is an entry.
If line.StartsWith("#") Then
ParseDirective(line)
Else
Dim access As LogFileEntry = ParseLogEntry(line)
' If the line was successfully parsed add the
LogFileEntry object to a collection.
If access IsNot Nothing Then
logFileEntries.Add(access)
End If
End If
Loop
End Using
' Return the collection of LogFileEntry objects.
Return logFileEntries
End Function
"Jon Skeet [C# MVP]" wrote:
Richard <Ri*****@discussions.microsoft.comwrote:
VB has the AscW function. There is no corresponding C# function. How can I do
this in C#? I do not want to reference the Microsoft.VisualBasic namespace
for just this function.
What *exactly* do you want to do? Bear in mind that every char is
already in Unicode. Are you trying to convert text into the default
encoding for the platform?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too