Not really.
Public Shared Function XYZ(ByVal x, ByVal y)
is just a shorthand in VB of writing
Public Shared Function XYZ(ByVal x As Object, ByVal y As Object) As Object
(yet another questionable 'feature' of VB...)
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter
Instant C++: VB to C++ converter
"Peter Bromberg [C# MVP]" wrote:
[color=blue]
> If the objects may be numbers but of differenty types and especially if they
> could be DbNull.Value then you are going to have to do some type checking in
> the method. Above all, as mentioned by other posters, with Option Strict and
> Option Explicit turned on as they always should be, your VB.NET method is not
> equivalent to the C# one, it's signature should be
>
> Public Shared Function XYZ(ByVal x as Object, ByVal y as Object)
>
> -- to be equivalent to the C# version.
>
> In general, I would have to agree that using VB.NET's weak GetObjectByValue
> semantics to avoid strict type checking is almost never a good idea.
>
> Peter
>
>
>
> --
> Co-founder, Eggheadcafe.com developer portal:
>
http://www.eggheadcafe.com
> UnBlog:
>
http://petesbloggerama.blogspot.com
>
>
>
>
> "Vik" wrote:
>[color=green]
> > I need to make some calculations, e.g. addition, on the objects x and y
> > which are numbers (of the same or different types) and may be DBNulls.
> >
> > In VB, the following code is correct:
> > Public Shared Function XYZ(ByVal x, ByVal y)
> > XYZ = x + y
> > End Function
> >
> > In C#, the identical code is wrong:
> > public static object XYZ(object x, object y) {
> > object z = x + y; //cannot add objects
> > return z;
> > }
> >
> > Should I write the different procedures in C# for the different data types
> > or is there a better way?
> >
> > Thanks.
> >
> >
> >[/color][/color]