473,406 Members | 2,371 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,406 software developers and data experts.

Default Property

I would like to achieve the following goal: design a class with a
default property called dVal where I could store and get a decimal value
WITHOUT the need to write the property.

I have the following code:

Dim Var as New VarDécimal
Var = 100 (instead of Var.dVal)

But I get an error telling me that a default property need to have a
parameter ! Why and what for ?
How to solve my problem ?

Thanks for your help
Bernard

Public Class VarDécimal
Private mNomVar As String
Private mVal As Decimal
Public Property Nom() As String
Get
Return mNomVar
End Get
Set(ByVal Value As String)
mNomVar = Value
End Set
End Property
Default Public Property dVal() As Decimal
Get
Return mVal
End Get
Set(ByVal Value As Decimal)
mVal = Value
End Set
End Property

End Class
Nov 21 '05 #1
1 1279
"Bernard Bourée" <be*****@bouree.net> schrieb:
I would like to achieve the following goal: design a class with a default
property called dVal where I could store and get a decimal value WITHOUT
the need to write the property.

I have the following code:

Dim Var as New VarDécimal
Var = 100 (instead of Var.dVal)

But I get an error telling me that a default property need to have a
parameter ! Why and what for ?
How to solve my problem ?


Default properties in .NET /must/ be parameterized to avoid ambiguity.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

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

Similar topics

3
by: CodeToad | last post by:
I am using the Windows MCAD/MCSD book on VB.NET/VC.NET to refresh myself on some C# concepts and I ran into one issue in the properties area I just do not understand. In VB.NET this is easy to...
5
by: Chuck Bowling | last post by:
Maybe I'm doing something wrong or just don't understand the concept, but i'm having a problem with default properties. My impression of how a default property should act is this; MyClass c =...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
4
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits...
2
by: Jon Paal | last post by:
Compiler Error Message: BC30367: Class 'System.Web.HttpContext' cannot be indexed because it has no default property. how do I create a "default property" ??
15
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this...
9
by: Eric | last post by:
Hi Everyone, I'm writing a UserControl that exposes a property of the type System.Drawing.Image, like this: Public Property DefaultImage() As Image Get Return propDefaultImage End Get...
1
by: murtyin | last post by:
Hi to All, I am creating COM Wrappers(CCW's) to the existing .Net Product, which is developed using C#. In this, am getting problem with setting "Item" propertty as the Default Property. My...
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.