Index: trunk/Include/Classes/System/String.ab
===================================================================
--- trunk/Include/Classes/System/String.ab	(revision 383)
+++ trunk/Include/Classes/System/String.ab	(revision 388)
@@ -61,5 +61,5 @@
 		Sub String(initStr As PCWSTR, start As Long, length As Long)
 			If start < 0 Or length Or start + length < 0 Then
-				'Throw New ArgumentOutOfRangeException
+				Throw New ArgumentOutOfRangeException("String constractor: One or more arguments are out of range value.", "start or length or both")
 			End If
 			validPointerCheck(initStr + start, length)
@@ -78,6 +78,6 @@
 
 		Sub String(initStr As PCSTR, start As Long, length As Long)
-			If start < 0 Or length Or start + length < 0 Then
-				'Throw New ArgumentOutOfRangeException
+			If start < 0 Or length < 0 Then
+				Throw New ArgumentOutOfRangeException("String constructor: One or more arguments are out of range value.", "start or length or both")
 			End If
 			validPointerCheck(initStr + start, length)
@@ -97,5 +97,5 @@
 		End Sub
 
-		Sub String(sb As System.Text.StringBuilder)
+		Sub String(sb As Text.StringBuilder)
 			Chars = StrPtr(sb)
 			m_Length = sb.Length
@@ -246,8 +246,7 @@
 
 		Function CompareTo(y As Object) As Long
-			Dim s = y As String
-	'		If y is not String Then
-	'			Throw New ArgumentException
-	'		End If
+			If Not Object.Equals(This.GetType(), y.GetType()) Then
+				Throw New ArgumentException("String.CompareTo: An argument is out of range value.", "y")
+			End If
 			Return CompareTo(y As String)
 		End Function
@@ -348,7 +347,10 @@
 		Const Function Contains(s As String) As Boolean
 			If Object.ReferenceEquals(s, Nothing) Then
-				'Throw New ArgumentNullException
-			End If
-			Return IndexOf(s, 0, m_Length) >= 0
+				Throw New ArgumentNullException("String.Contains: An argument is out of range value.", "s")
+			ElseIf s = "" Then
+				Return True
+			Else
+				Return IndexOf(s, 0, m_Length) >= 0
+			End If
 		End Function
 
@@ -385,6 +387,5 @@
 			rangeCheck(startIndex, count)
 			If Object.ReferenceEquals(s, Nothing) Then
-				'Throw New ArgumentNullException
-				Debug
+				Throw New ArgumentNullException("String.IndexOf: An argument is out of range value.", "s")
 			End If
 
@@ -405,4 +406,34 @@
 		End Function
 
+		Const Function LastIndexOf(c As StrChar) As Long
+			Return lastIndexOf(c, m_Length - 1, m_Length)
+		End Function
+
+		Const Function LastIndexOf(c As StrChar, start As Long) As Long
+			rangeCheck(start)
+			Return lastIndexOf(c, start, start + 1)
+		End Function
+
+		Const Function LastIndexOf(c As StrChar, start As Long, count As Long) As Long
+			rangeCheck(start)
+			Dim lastFindPos = start - (count - 1)
+			If Not (m_Length > lastFindPos And lastFindPos >= 0) Then
+				Throw New ArgumentOutOfRangeException("String.LastIndexOf: An argument is out of range value.", "count")
+			End If
+			Return lastIndexOf(c, start, count)
+		End Function
+	Private
+		Const Function lastIndexOf(c As StrChar, start As Long, count As Long) As Long
+			Dim lastFindPos = start - (count - 1)
+			Dim i As Long
+			For i = start To lastFindPos Step -1
+				If Chars[i] = c Then
+					Return i
+				End If
+			Next
+			Return -1
+		End Function
+
+	Public
 		Const Function LastIndexOf(s As String) As Long
 			Return LastIndexOf(s, m_Length - 1, m_Length)
@@ -413,21 +444,19 @@
 		End Function
 
-		Const Function LastIndexOf(s As String, startIndex As Long, count As Long) As Long
+		Const Function LastIndexOf(s As String, start As Long, count As Long) As Long
 			If Object.ReferenceEquals(s, Nothing) Then
-				'Throw New ArgumentNullException
-				Debug
-			End If
-
-			If startIndex < 0 Or startIndex > m_Length - 1 Or _
-				count < 0 Or count > startIndex + 2 Then
-				'Throw New ArgumentOutOfRangeException
-				Debug
-			End If
-			Dim length = s.Length
+				Throw New ArgumentNullException("String.LastIndexOf: An argument is out of range value.", "s")
+			End If
+
+			If start < 0 Or start > m_Length - 1 Or _
+				count < 0 Or count > start + 2 Then
+				Throw New ArgumentOutOfRangeException("String.LastIndexOf: One or more arguments are out of range value.", "start or count or both")
+			End If
+			Dim length = s.m_Length
 			If length > m_Length Then Return -1
-			If length = 0 Then Return startIndex
+			If length = 0 Then Return start
 
 			Dim i As Long, j As Long
-			For i = startIndex To  startIndex - count + 1 Step -1
+			For i = start To  start - count + 1 Step -1
 				For j = length - 1 To 0 Step -1
 					If Chars[i + j] = s[j] Then
@@ -450,5 +479,5 @@
 
 		Const Function Insert(startIndex As Long, text As String) As String
-			Dim sb = New System.Text.StringBuilder(This)
+			Dim sb = New Text.StringBuilder(This)
 			sb.Insert(startIndex, text)
 			Return sb.ToString
@@ -471,5 +500,5 @@
 
 		Const Function Remove(startIndex As Long, count As Long) As String
-			Dim sb = New System.Text.StringBuilder(This)
+			Dim sb = New Text.StringBuilder(This)
 			sb.Remove(startIndex, count)
 			Remove = sb.ToString
@@ -486,5 +515,5 @@
 
 		Const Function Replace(oldChar As StrChar, newChar As StrChar) As String
-			Dim sb = New System.Text.StringBuilder(This)
+			Dim sb = New Text.StringBuilder(This)
 			sb.Replace(oldChar, newChar)
 			Replace = sb.ToString
@@ -492,5 +521,5 @@
 
 		Const Function Replace(oldStr As String, newStr As String) As String
-			Dim sb = New System.Text.StringBuilder(This)
+			Dim sb = New Text.StringBuilder(This)
 			sb.Replace(oldStr, newStr)
 			Return sb.ToString
@@ -498,9 +527,9 @@
 
 		Const Function ToLower() As String
-			Dim sb = New System.Text.StringBuilder(m_Length)
+			Dim sb = New Text.StringBuilder(m_Length)
 			sb.Length = m_Length
 			Dim i As Long
 			For i = 0 To ELM(m_Length)
-				sb[i] = _System_ASCII_ToLower(Chars[i])
+				sb[i] = ActiveBasic.CType.ToLower(Chars[i])
 			Next
 			Return sb.ToString
@@ -508,9 +537,9 @@
 
 		Const Function ToUpper() As String
-			Dim sb = New System.Text.StringBuilder(m_Length)
+			Dim sb = New Text.StringBuilder(m_Length)
 			sb.Length = m_Length
 			Dim i As Long
 			For i = 0 To ELM(m_Length)
-				sb[i] = _System_ASCII_ToUpper(Chars[i])
+				sb[i] = ActiveBasic.CType.ToUpper(Chars[i])
 			Next
 			Return sb.ToString
@@ -539,5 +568,5 @@
 			Dim size = m_Length
 #endif
-			Return _System_GetHashFromWordArray(Chars As *Word, size) Xor size
+			Return _System_GetHashFromWordArray(Chars As *Word, size) Xor m_Length
 		End Function
 
@@ -548,10 +577,10 @@
 		Function PadLeft(total As Long, c As StrChar) As String
 			If total < 0 Then
-				'Throw New ArgumentException
+				Throw New ArgumentOutOfRangeException("String.PadLeft: An arguments is out of range value.", "total")
 			End If
 			If total >= m_Length Then
 				Return This
 			End If
-			Dim sb = New System.Text.StringBuilder(total)
+			Dim sb = New Text.StringBuilder(total)
 			sb.Append(c, total - m_Length)
 			sb.Append(This)
@@ -565,10 +594,10 @@
 		Function PadRight(total As Long, c As StrChar) As String
 			If total < 0 Then
-				'Throw New ArgumentException
+				Throw New ArgumentOutOfRangeException("String.PadRight: An arguments is out of range value.", "total")
 			End If
 			If total >= m_Length Then
 				Return This
 			End If
-			Dim sb = New System.Text.StringBuilder(total)
+			Dim sb = New Text.StringBuilder(total)
 			sb.Append(This)
 			sb.Append(c, total - m_Length)
@@ -596,5 +625,5 @@
 		Const Sub rangeCheck(index As Long)
 			If index < 0 Or index > m_Length Then
-				Debug 'ArgumentOutOfRangeException
+				Throw New ArgumentOutOfRangeException("String: An arguments is out of range value.", "index")
 			End If
 		End Sub
@@ -602,5 +631,5 @@
 		Const Sub rangeCheck(start As Long, length As Long)
 			If start < 0 Or start > This.m_Length Or length < 0 Then
-				Debug 'ArgumentOutOfRangeException
+				Throw New ArgumentOutOfRangeException("String: One or more arguments are out of range value.", "start or length or both")
 			End If
 		End Sub
