473,587 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# MC++ and "explicit implementation" for interfaces

Hi, have been searching for an answer for this for quite a while,I would be greatfull for any help.

We are developing a codebase that of components that we wouldlike to be able to write in MC++ or C# depending on thesituation. These components are accessed through a standard setof interfaces that we have defined in C#. We are using"explicit implementation" for these interfaces as thesecomponents may implement many interfaces, often with similarmethod/property names, as well as for containment.

What I would like to do is have the components appear exacly thesame from the outside, but they currently do not. The problemis that when I explicitly implement an interface in C#, themethods of the interfaces are not accessible from the classinstance (desired result). On the other hand, when I implementthe same interface in MC++, the methods are accessible from theclass instance. (would like to avoid this)

Example code:

C# component:
_______________ _______________ _______________ _______________ ______
namespace Foo
{
public interface IBar
{
void DoStuff();
}
public class Foo : IBar
{
Foo()
{
}

void IBar.DoStuff()
{
// Do Stuff Here
}
}
}

MC++ component:
_______________ _______________ _______________ _______________ ______
// Foo2.h
namespace Foo
{
public __gc class CFoo2 : public IBar
{
CFoo2();
void IBar::DoStuff() ;
}
}

// Foo2.cpp
#include "Foo2.h"

CFoo2::CFoo2()
{
}

CFoo2::IBar::Do Stuff()
{
// Do Stuff here
}

C# consumer of component:
_______________ _______________ _______________ _______________ ______
using namespace Foo;

namespace user
{
public class User
{
User()
{
// Using the C# component
Foo CSComponent = new Foo();
//CSComponent.DoS tuff(); // Compiler error
((IBar)CSCompon ent).DoStuff(); // No problem thisworks

// Using the MC++ component
Foo2 MCppComponent = new MCppComponent() ;
MCppComponent.D oStuff(); // This works but Iwish it wouldn't
((IBar)MCppComp onent.DoStuff() ; // Add of course thisworks
}
}
}

Is it possible to get the same behaviour, or do C# and MCpp treatexplicit interface implementation differently?

As a side note, I would appreciate any recommendation for goodliterature, websites for managed C++. Through all of myresearch on the web it appears that the documentation on MC++ israther slim, whereas for C# there seems to be a wealth ofinformation.

Much appreciated,
Peter

--------------------------------
From: Peter Insley

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>21c6H3XlqEW iJaWVQUeT/A==</Id>
Nov 17 '05 #1
0 1208

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1733
by: lpe | last post by:
http://www.pycode.com I was kinda suprised when I could not find any good sites with 3rd party modules (other than the Vaults of Parnassus, where you must host files elsewhere), so I decided to write one myself :) It is brand new and might still be buggy, but hopefully it will be usefull to some people. Feel free to join and upload any of your code. thanks
6
1922
by: wyhang | last post by:
I want a implementation just like the "join" in the unix shell, I googled the web and found nothing. Any suggestion will be highly appreciated, thank you~
3
3805
by: Gergely Varadi | last post by:
public class A : IComparable { int IComparable.CompareTo(object obj) { return 1; } } /// <summary> /// <see cref="A.System.IComparable.CompareTo"/>
1
7500
by: Phil Sandler | last post by:
Hello all, Thanks in advance for any help with this. I am trying to get sample code to run from Michael Russell's excellent article on removing whitespace: http://www.codeproject.com/aspnet/WhitespaceFilter.asp I have also tried his updated version, which can be found (in a zip file) here:
1
10405
by: Mitan | last post by:
Hello, I'm a beginner with what appears to be a simple question for which I haven't been able to get an answer. Can someone explain what "implementation code" is in relation to VB.NET? I want to be sure I have a good understanding of this before I continue with my studies. Thanks in advance. Semper Fi
8
11434
by: kevin | last post by:
I have a form and in the form I have a sub that uses a class I instantiate using visual basic code: Public oCP As New Rs232 'instantiate the comm port I need to share this sub with another form so to declare the sub I use visual basic code: Public Shared Function IsPortAvailable(ByVal ComPort As Integer) As Boolean
2
2697
by: Praveen Chandra | last post by:
Hi, I am trying to build a static library, while building the library i am getting the following error: fatal error C1189: #error : "No sstream/strstream implementation" Following is the code that is giving error: #ifdef HAVE_CONFIG_H
5
4077
by: Nicolas Pontoizeau | last post by:
Hi, I am handling a mixed languages text file encoded in UTF-8. Theres is mainly French, English and Asian languages. I need to detect every asian characters in order to enclose it by a special tag for latex. Does anybody know if there is a unicode "table of character" implementation in python? I mean, I give a character and python replys me with the language in which the character occurs. Thanks in advance
1
1607
by: webtourist | last post by:
Warning: New learner here Not sure what the term means "implementation of Python". So what exactly does it mean *"implementation of Python"* like cpython, Jython, IronPython ????? In terms of IronPython --- does it mean a Python programmer can write .Net app in Python ? Thanks
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.