.net - Translate this C# comparison to VB.NET -


i'm trying translate comparison between 2 nullable(of byte) objects:

    public byte?[] header { get; private set; }      public override bool equals(object other)     {         // ... more code translate         if (this.header != othertype.header) return false;         // ... more code translate     } 

an online code translator gives me equivalent:

    private m_header nullable(of byte)()     public property header() nullable(of byte)()                     return m_header         end         private set(value nullable(of byte)())             m_header = value         end set     end property      public overrides function equals(other object) boolean          ' ... more code translated         if me.header <> othertype.header             return false         end if         ' ... more code translated      end function 

but exception:

operator '<>' not defined types '1-dimensional array of byte?' , '1-dimensional array of byte?'. use 'is' operator compare 2 reference types.

then, detail of exception says, know if should proper translation 'cause i'm not totally sure:

if not me.header othertype.header     return false end if 

you use null-coalescing operator treat null-byte 0:

public overrides function equals(other object) boolean     ' ... '     dim othertype = trycast(other, actualtype)     if othertype nothing return false     if if(me.header, 0) <> if(othertype.header, 0)         return false     end if     ' ... ' end function 

here approach checks if both nullable-arrays equal:

if header nothing andalso othertype.header nothing     return true elseif object.referenceequals(header, othertype.header)     return true elseif header nothing orelse othertype.header nothing     return false else     return header.sequenceequal(othertype.header) end if 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -