.net - Why does COM Interop treat a VB6 Boolean as C# Short? -
.net - Why does COM Interop treat a VB6 Boolean as C# Short? -
i have legacy vb6 application has next construction defined:
public type drawdown date date amount currency capitaliseinterest boolean end type an interop assembly generated using tlbimp.exe construction ends following:
[structlayout(layoutkind.sequential, pack = 4)] public struct drawdown { public datetime date; [marshalas(unmanagedtype.currency)] public decimal amount; public short capitaliseinterest; } i'm using .net 4.0.
why vb6 boolean translated c# short instead of bool?
vb6 uses variant_bool type,
find info , history here: bool vs. variant_bool vs. boolean vs. boo
off side came variant_bool.
typedef short variant_bool; define variant_true ((variant_bool)-1) define variant_false ((variant_bool)0) developed visual basic folks. basic uses -1 represent "true" , 0 represent "false", , variant_bool designed preserve behavior.
c# .net com vb6 com-interop
Comments
Post a Comment