Index | General .NET |
GuidAttribute
with a unique GUID valueProgIdAttribute
public
members are accessible under COM (no protected
etc.)new
)
at inheriting interfacenew
are accessible only after specific cast (implement cast methods for that)ref
,
out
)
must be implemented of COM type Variant
(Object
)VARIANT
structure);
known types without equivalent in VBScript are
Byte
andVariant
(Object
)public
abstract
classes are possibleComVisibleAttribute
of value false
For Each
enumerable support for COM needs direct IEnumerator
GetEnumerator()
method implementation, could be done with IEnumerable
interface with precidence over IEnumerable<T>
(type library exporter exports as IEnumVARIANT
and give them the DispId
of -4 / 0xFFFFFFFC
for a _NewEnum implementation)Object
,
so Linq
Cast<Object>().ToArray()
would help here and for in correct cast then the incoming elementsHandling of optional parameters by params
in (VB/VBA/VBScript as ParamArray
) requires an implementation as COM type Variant
(Object
) array.
The framework handles this as a SAFEARRAY(VARIANT).
When exporting the type library (TLB) with TlbExp
it becomes a vararg
attribute there also.
Specific implementation and change in TLB/IDL is required for VB, while VBScript can direct use it.
MT
for that)CreateObject(...)
(VBA,
VBScript) error will occur when
params
VBScript
)MyParamArrayMethod(params Object[] values)
Results in VB
MyParamArrayMethod(ByVal ParamArray values() As Object)
Being in IDL
[id(1), vararg]
HRESULT MyParamArrayMethod([in] SAFEARRAY(VARIANT) values);
MyParamArrayMethod(ref Object[] values)
Should result in VB
MyParamArrayMethod(ByVal ParamArray values() As Object)
Requires in IDL
[id(1), vararg]
HRESULT MyParamArrayMethod([in] SAFEARRAY(VARIANT)* values);
For Each
enumerator with generic IEnumerable<T>
implementationpublic class ForEachSample :
IEnumerable<String>
{
private readonly List<String> _list = new List<String>();
public ForEachSample()
{
}
public IEnumerator GetEnumerator() => ((IEnumerable<String>)this).GetEnumerator();
IEnumerator<String> IEnumerable<String>.GetEnumerator() => _list.GetEnumerator();
}
© SphereSoft.NET, Holger Boskugel, Berlin, Germany spheresoft.net