473,624 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing Interfaces in C#

Hello Everyone,

I am implementing a simple interface in C# using Visual Studio .net and was
quite surprised to discover that the C# compiler does NOT complain if a
method on the interface is not implemented.

VB.net on the other hand generates a compile error if a method is not
implemented. This helps in ensuring that all interface methods are
implemented.

The fact that C# does not provide such compile errors makes implementing and
interface in C# more labor intensive than in VB.net. You have to use the
object browser and check the function signature, etc.

Is this normal behavior? Could I possibly be doing something wrong?

Any help would be appreciated.

Regards,
Frank J. Reashore

Vancouver, Canada



Nov 15 '05 #1
4 2057
It gives me an error, "Class1 does not implement interface member ABC.DoSomething ()"
public interface ABC
{
void DoSomething();
}
public class Class1 : ABC
{
public Class1()
{
}
}

--
Michael Culley
"Frank J. Reashore" <re******@NOSPA MTelus.net> wrote in message news:OK******** ******@TK2MSFTN GP09.phx.gbl...
Hello Everyone,

I am implementing a simple interface in C# using Visual Studio .net and was
quite surprised to discover that the C# compiler does NOT complain if a
method on the interface is not implemented.

VB.net on the other hand generates a compile error if a method is not
implemented. This helps in ensuring that all interface methods are
implemented.

The fact that C# does not provide such compile errors makes implementing and
interface in C# more labor intensive than in VB.net. You have to use the
object browser and check the function signature, etc.

Is this normal behavior? Could I possibly be doing something wrong?

Any help would be appreciated.

Regards,
Frank J. Reashore

Vancouver, Canada


Nov 15 '05 #2
Michael
I always get an error if I don't implement an Interface method.

With Regards

Deepa
[I code, therefore I am
----- Michael Culley wrote: ----

It gives me an error, "Class1 does not implement interface member ABC.DoSomething ()
public interface AB

void DoSomething()

public class Class1 : AB

public Class1(


-
Michael Culle
"Frank J. Reashore" <re******@NOSPA MTelus.net> wrote in message news:OK******** ******@TK2MSFTN GP09.phx.gbl..
Hello Everyone
I am implementing a simple interface in C# using Visual Studio .net and wa

quite surprised to discover that the C# compiler does NOT complain if
method on the interface is not implemented
VB.net on the other hand generates a compile error if a method is no

implemented. This helps in ensuring that all interface methods ar
implemented
The fact that C# does not provide such compile errors makes implementing an

interface in C# more labor intensive than in VB.net. You have to use th
object browser and check the function signature, etc
Is this normal behavior? Could I possibly be doing something wrong
Any help would be appreciated
Regards

Frank J. Reashor
Vancouver, Canad
>>>

Nov 15 '05 #3
Hi Frank, It's would be best to post the source (pref a simplified version)
that you believe to be compiling without errors. As others have noted you
should see compile errors if an interface method is not implemented.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Frank J. Reashore" <re******@NOSPA MTelus.net> wrote in message
news:OK******** ******@TK2MSFTN GP09.phx.gbl...
Hello Everyone,

I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a
method on the interface is not implemented.

VB.net on the other hand generates a compile error if a method is not
implemented. This helps in ensuring that all interface methods are
implemented.

The fact that C# does not provide such compile errors makes implementing and interface in C# more labor intensive than in VB.net. You have to use the
object browser and check the function signature, etc.

Is this normal behavior? Could I possibly be doing something wrong?

Any help would be appreciated.

Regards,
Frank J. Reashore

Vancouver, Canada


Nov 15 '05 #4
There have been times when I'm pulling my hair out WISHING C# wouldn't give
me an error when implementing an interface, but no such luck.

Visual C# in the Visual Studio 2003 IDE give me a fatal error if I attempt
to compile an app that does not have all methods of an inherited interface
defined.

Please post an example of what you are seeing. Perhaps we can help you to
find the issue.

--- Nick

"Frank J. Reashore" <re******@NOSPA MTelus.net> wrote in message
news:OK******** ******@TK2MSFTN GP09.phx.gbl...
Hello Everyone,

I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a
method on the interface is not implemented.

VB.net on the other hand generates a compile error if a method is not
implemented. This helps in ensuring that all interface methods are
implemented.

The fact that C# does not provide such compile errors makes implementing and interface in C# more labor intensive than in VB.net. You have to use the
object browser and check the function signature, etc.

Is this normal behavior? Could I possibly be doing something wrong?

Any help would be appreciated.

Regards,
Frank J. Reashore

Vancouver, Canada


Nov 15 '05 #5

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

Similar topics

1
14922
by: MKoleoso | last post by:
Problem: C#- Unable to create instance of a class implementing from an interface I have: namespace someNamespace { public __gc class SomeClass1 { }
6
2752
by: Martyn Lawson | last post by:
Hi, I am currently working as an Analyst on a .NET Web Project using ASP.NET and C#.NET. I have a couple of, at least what should be, quick questions: 1. My understanding of UML says that the Controller classe of a Sequence Diagram should be implemented as a private class within a component. However, my Programmer has said that since the ASP code lives outside the
7
17188
by: mdc | last post by:
Hi, Is there any way to implement an interface as a static method in C#? If not, is this a bug? Micheal.
1
1342
by: Devon | last post by:
Hi, I'm just getting my feet wet with C# and need some help with interface implementation. I want to create a collection of various objects that implement a certain interface (i.e. IMyInterface). Each object will have additional methods which are unique to their class. The collection will only accept types IMyInterface but I want to be able to access any object in the collection via the interface or the implementing class. Is this...
2
7106
by: Robb Sadler | last post by:
I am trying to write several hardware interfaces that would use the same base class and functions and be implemented differently. I don't want to ship all of the interfaces, but want to access them using the same generic base class. I have seen that I can use the Assembly.load method to load the implementation I need for the hardware being connected to, but wish to write the code such that I can reference the methods of the class...
1
2463
by: Andreas Mueller | last post by:
Hi, I have a struct that implements an interface: interface IMyInterface { void DoIt(); } public struct MyStruct : IMyInterface {
0
1002
by: Matt Sipes via DotNetMonster.com | last post by:
my C# code interface: namespace IShared; { public interface IChannelEntity { void SendMsg(string p_msg); void Exit(); } public interface IChannelEntityCallBack
1
1860
by: oldVB3r | last post by:
I would like to create a set of web services that share a common set of types (classes, structures, enums). I know I can create a VS 2005 web service based on the Interface statement to contain these common types. The problem is that I cannot determine how to create the implementation web services in a way that I can cast the common types between proxy object parameters in a client app. Please check the snippets of my code: 'Interface...
13
2110
by: interec | last post by:
I have some code in Java that I need to translate into C++. My Java code defines a class hierarchy as follows: // interface IA public interface IA { public abstract void doA(); } // interface IB
0
8168
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
8672
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
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
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
7153
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...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
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.