| |

VerySource

 Forgot password?
 Register
Search
View: 880|Reply: 6

How does the .net program use the com interface inheritance relationship?

[Copy link]

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-26 17:00:01
| Show all posts |Read mode
How does the .net program use the com interface inheritance relationship?

For example, the Com class "ComClass" inherits the Com interface "ComInterface", but after .net references them, ComClass and ComInterface are irrelevant. If you write
ComInterface obj = new ComClass();
It is reported that it cannot be converted. May I ask ComClass to be converted to ComInterface?
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-11-26 19:15:02
| Show all posts
By the way, is it troublesome for .net to use com components? I think the c# language does not support com features such as optional parameters, default members, etc. I don't know if vb.net is better.
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-11-27 17:45:01
| Show all posts
By the way, for the optional parameters of the com method in c#, what to pass is equivalent to not passing it? What is the equivalent of "Missing" in com?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-11-27 18:30:01
| Show all posts
You can pass Type.Missing
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-11-28 10:00:01
| Show all posts
darknesslan
Type.Missing doesn't seem to work. For example, the optional parameter is of int type. Type.Missing obviously does not match the int type.
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-11-28 10:15:01
| Show all posts
Is there any expert who can help to solve it?
Reply

Use magic Report

1

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-11-28 12:30:02
| Show all posts
Just found out that it’s okay to turn around, Khan!
ComInterface obj = (ComInterface)(new ComClass());

Thank you for your participation!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list