Transalation

  • Thread starter Thread starter A.M
  • Start date Start date
A

A.M

Could anybody translate this function into C# please?
Thanks,
Ali


Public Shared Function NzDataReader(ByVal v As Object, Optional ByVal z As
Object = "", Optional ByVal NullClass As String = "System.DBNull")
Try
If v.GetType.ToString = NullClass Then
Return z
Else
Return v
End If
Catch e As Exception
ErrorHandler(e)
End Try
End Function
 
A.M,

Here it is.

public static object NzDataReader(object v, object z, string NullClass)
{
// The return value.
object pobjRetVal = null;

try
{
if (v.GetType().ToString() == NullClass)
pobjRetVal = z;
else
pobjRetVal = v;
}
catch (Exception e)
{
ErrorHandler(e);
}

// Get out.
return pobjRetVal;
}

Now, since optional parameters are not supported in C#, you will have to
declare two overloads:

public static object NzDataReader(object v, object z)
{
// Call the overload.
return NzDataReader(v, z, "System.DBNull");
}

public static object NzDataReader(object v)
{
// Call the overload.
return NzDataReader(v, string.Empty);
}

Hope this helps.
 
Hi Ali,

Does Nicholas's C# code meet your need?
If it does not work on your side, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top