 |
|
|
Topic: compatibility with c #
|
By: reyna | Posted on: Nov 11 2015 at 05:13:35 PM |
a question
this dll is compatible with C # and the Common use it because I have that I use for the port, for example:
SComm1.PortOpenme appears AxSComm1.set_PortOpen (True) | |
By: Guest | Posted on: Nov 12 2015 at 09:51:11 PM | Yes. The .Net framework exposes the get/set and makes all of the methods work like functions where the value is passed as an argument in brackets.
These examples assume you've named the component 'Port'
Reading and writing a property in VB6
If (Port.PortOpen = False) Then
Port.PortOpen = True
End if
Doing the same in VB.Net
If Port.get_PortOpen = False then
Port.set_PortOpen(True)
End If
' Property names are prefixed with get_ or set_ (indicating read or write) and when setting a property the new value is passed in brackets just like a function call.
Doing the same in C#
bool b = true; // Notice this variable - we didn't need this in VB
if(Port.get_PortOpen() == false)
{
Port.set_PortOpen(ref b);
}
/* c# is even stricter - notice that we used empty brackets even when reading the property. Also notice the 'ref' keyword when setting the new value. By Default Visual Basic passes arguments 'By Ref'. In c# that isn't the case but we still need to pass the value by ref. Adding the ref keyword tells c# that you want to pass it by ref. Because you're passing an argument by ref it's cleaner if you use a variable. In this case we declared b as a boolean, set it to true and passed that by ref. */
But also take a look at:
www.comm64.com
| |
|