Eto kakvi su ovi c# zealoti hehe, sve bi ucinili samo da ne dodaju reference na Microsoft.VisualBasic.dll :) :)
Namespace: Microsoft.VisualBasic
Module: Information
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Public Function IsNumeric(ByVal Expression As Object) As Boolean
Kada se pokrene Lutz Roeder's reflector dobije se sadrzina funkcije pa prepisi u c#.
Code:
Public Shared Function IsNumeric(ByVal Expression As Object) As Boolean
Dim num1 As Double
Dim convertible1 As IConvertible = TryCast(Expression,IConvertible)
If (convertible1 Is Nothing) Then
Dim chArray1 As Char() = TryCast(Expression,Char())
If (Not chArray1 Is Nothing) Then
Expression = New String(chArray1)
Else
Return False
End If
End If
Dim code1 As TypeCode = convertible1.GetTypeCode
If ((code1 <> TypeCode.String) AndAlso (code1 <> TypeCode.Char)) Then
Return Information.IsOldNumericTypeCode(code1)
End If
Dim text1 As String = convertible1.ToString(Nothing)
Try
Dim num2 As Long
If Utils.IsHexOrOctValue(text1, num2) Then
Return True
End If
Catch exception1 As StackOverflowException
Throw exception1
Catch exception2 As OutOfMemoryException
Throw exception2
Catch exception3 As ThreadAbortException
Throw exception3
Catch exception7 As Exception
Return False
End Try
Return DoubleType.TryParse(text1, num1)
End Function
Mada imas onu try...catch hack foru koja je cak i dobra, jeste da imas "try" overhead
Code:
public bool IsNumeric(object o)
{
try
{
Int32.Parse(o);
}
catch
{
return false;
}
return true;
}
http://www.pro-transport.com - The most advanced trucking software on the market