473,626 Members | 3,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override MustOveride String property in MustInherit class error

I created a Mustinherit class with two must override readonly properties:

Public MustInherit Class RequestPart
Public MustOverride ReadOnly Property Description() As Boolean
Public MustOverride ReadOnly Property Mandatory() As String
End Class

I the derived class I cannot override the property Mandatory because the
return types differ:

Public Class Login
Inherits RequestPart
Private _Username As String
Private _Password As String
Private _Description As String
Public ReadOnly Property Description() As String
Get
Return _Description
End Get
End Property

Public ReadOnly Property Mandatatory() As Boolean
Get
Return True
End Get
End Property
and so on....

Why do I get the error that the return types differ?

Nov 21 '05 #1
3 2757

"Philip Wagenaar" <ph************ *@online.nospam > wrote in message
news:2D******** *************** ***********@mic rosoft.com...
Why do I get the error that the return types differ?


Because the return types differ.

When you override a function, you must use the same signature as the
function you are overriding. Otherwise you are overloading, which cannot
differ ONLY by return type.

Nov 21 '05 #2
You have the return types inverted

Base
- Description => Boolean
- Mandatory => String

Derived
- Description => String
- Mandatory => Boolean
hth,
Alan.

Nov 21 '05 #3
In RequestPart, Description is Boolean, Mandatory is String.
In Login, Description is String, Mandatory is Boolean.

I guess you simply mixed them up in RequestPart class.

Also, in Login Class overrided properties should be marked as Overrides;
see example:

~
Public MustInherit Class RequestPart
Public MustOverride ReadOnly Property Description() As String
Public MustOverride ReadOnly Property Mandatory() As Boolean
End Class

Public Class Login
Inherits RequestPart
Private _Username As String
Private _Password As String
Private _Description As String
Public Overrides ReadOnly Property Description() As String
Get
Return _Description
End Get
End Property

Public Overrides ReadOnly Property Mandatory() As Boolean
Get
Return True
End Get
End Property
End Class
~

Roman
Nov 21 '05 #4

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

Similar topics

5
5909
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int Count { get { return 0; }
9
2062
by: Ken Varn | last post by:
Is there anyway to override a public virtual method or property so that it is private in my derived class? I tried using new on the property and making it private, but no luck. -- ----------------------------------- Ken Varn Senior Software Engineer Diebold Inc.
2
3864
by: Josef Meile | last post by:
Hi, I have this constructor: public CExcelDatabase(string host, string user, string password, string database, bool promptCredentials, int findExcelInstance, bool readOnly) { //Some code comes here
9
7123
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but when I tried the program on the Win98 system it will be running on, I get the following error: Cast from string "2076719" to type 'Long' is not valid I am not sure why I only get this error on the Win98 system or how to go about correcting...
7
1751
by: Frank | last post by:
Hi, a question probably asked before, but I can't find the answers. Base class X, classes A, B and C inherit class X. In class A I do not want to inherit property (or function or method) P1. Possible? How? Thanks in advance Frank
4
2170
by: Stephen Costanzo | last post by:
My goal is to have a property or function that returns different types of returns with no initial arguments. For example Public Class Something Private sData as string Private lData as long Public Property X () as String Get
4
8627
by: Gary12009 | last post by:
Hello All, I have two classes, only the type of one of the properties is different. How should I declare the two classes? For example: I want to declare 2 Classes, named MySQLIntfield and MySQLStrField. Both have the Name and Value properties, but one of the type of value property is string and the other is Int. Their Methods are common, like get NameValue string or getNameValue xml
14
33257
by: Dave Booker | last post by:
It looks like the language is trying to prevent me from doing this sort of thing. Nevertheless, the following compiles, and I'd like to know why it doesn't work the way it should: public class ComponentA { static string s_name = "I am the root class."; public string Name { get {return s_name;} } }
1
3095
by: Joshua | last post by:
I'm creating a web control that has an image and a text box. I would like to then override the Visible and Text property of the usercontrol, so when you reference the visible property of the user control it only set the visible property of the textbox. When i call these newly created property I get the following error: Object reference not set to an instance of an object. Does anybody have any idea? Thank you.
0
8199
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
8638
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
8365
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
7196
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
5574
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
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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.