473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

virtual override

Hi,

In a mangaed C++ wrapper class, I have some pure virtual function
declarations:

public __gc __abstract class CESCSAPICommand
{
......
// Test only
virtual bool Test(int i1, int i2) = 0;

// SendPacket() takes address and size of a byte array buffer:
virtual bool SendPacket(unsigned char packetAddress __nogc[], int
packetSize) = 0;
.....
}

When trying to override these in a C# application, this works fine for a
simple Test() method just using 2 intergers.
However, I have no chance to override SendPacket()!

My relevant C# code looks as follows:

class CESCSMyAPICommand: CESCSAPICommand
{
.....
public override bool Test(int i1, int i2) {...} // compiles
and works fine, but....

public override bool SendPacket(byte [] packetAddress , int
packetSize)
{
.....
socket.Send(packetAddress , 0, packetSize, 0);
.....
}

// ... causes compiler error s:
'ConsoleApplication1.CESCSMyAPICommand' does not implement
inherited abstract
member 'CESCSAPICommand.SendPacket(byte*, int)'

'ConsoleApplication1.CESCSMyAPICommand' .SendPacket(byte[],
int)': no suitable method found to override
....
}

What is wrong? In other words: how do I correclty declare my pure
virtual function SendPacket(bufferAddress,bufferSize) in managed C and
override it in a C# application so that I cann pass the parameters to
Socket:Send() ??

Thanks in advance
Urs

PS: remove leading / trailing ns_, _ns from e-mail address

Nov 15 '05 #1
1 4723
Urs,

I believe that you want something like this:

virtual bool SendPacket(byte packetAddress __gc[], int packetSize) = 0;

The __gc indicates that the array is a managed array.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Urs Wigger" <ns_urs.wigger@leica-geosystems_ns.com> wrote in message
news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi,

In a mangaed C++ wrapper class, I have some pure virtual function
declarations:

public __gc __abstract class CESCSAPICommand
{
......
// Test only
virtual bool Test(int i1, int i2) = 0;

// SendPacket() takes address and size of a byte array buffer:
virtual bool SendPacket(unsigned char packetAddress __nogc[], int
packetSize) = 0;
.....
}

When trying to override these in a C# application, this works fine for a
simple Test() method just using 2 intergers.
However, I have no chance to override SendPacket()!

My relevant C# code looks as follows:

class CESCSMyAPICommand: CESCSAPICommand
{
.....
public override bool Test(int i1, int i2) {...} // compiles
and works fine, but....

public override bool SendPacket(byte [] packetAddress , int
packetSize)
{
.....
socket.Send(packetAddress , 0, packetSize, 0);
.....
}

// ... causes compiler error s:
'ConsoleApplication1.CESCSMyAPICommand' does not implement
inherited abstract
member 'CESCSAPICommand.SendPacket(byte*, int)'

'ConsoleApplication1.CESCSMyAPICommand' .SendPacket(byte[],
int)': no suitable method found to override
....
}

What is wrong? In other words: how do I correclty declare my pure
virtual function SendPacket(bufferAddress,bufferSize) in managed C and
override it in a C# application so that I cann pass the parameters to
Socket:Send() ??

Thanks in advance
Urs

PS: remove leading / trailing ns_, _ns from e-mail address

Nov 15 '05 #2

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

Similar topics

32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
4
by: Rafael Veronezi | last post by:
I have some questions about override in inheritance, and virtual members. I know that you can you override a method by two ways in C#, one, is overriding with the new keyword, like: public new...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
8
by: JPRoot | last post by:
Hi M. Jeffrey Tan, Just hopping you didn't forget me? :) Thanks JPRoot ----- \"Jeffrey Tan\" wrote: -----
4
by: Jazper Manto | last post by:
hi what is the difference between virtual / override and new? until now i only knew the virtual / override thing. thanx for hint. Jazper //--- new ----------------------------------------...
5
by: Mark Broadbent | last post by:
Oh yes its that chestnut again! Ive gone over the following (http://www.yoda.arachsys.com/csharp/faq/ -thanks Jon!) again regarding this subject and performed a few of my own tests. I have two...
15
by: John Salerno | last post by:
Hi all. I have a question about virtual and override methods. Please forgive the elementary nature! First off, let me quote Programming in the Key of C#: "Any virtual method overridden with...
5
by: Marcel Hug | last post by:
Hi NG ! I'm new in C# and I'm reading a book about the fundamentals and concepts. In the chapter Methods it's written to use virtual, if i would like to override the method in a subclass. This...
8
by: Karsten Schramm | last post by:
Hi, when I run the following code: using System; namespace ConsoleApplication22 { class Program {
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.