473,406 Members | 2,549 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.

Properties with different get and set types

PLS
VB.NET allows defining a property that has different get and set types
by doing this
Public Property fFlag(ByVal flag as flagEnumeration) As Boolean
Get
Return ...
End Get
Set(ByBal Value as Boolean)
...
End Set
End Property

What is the C# equivalent of this?

Thanks,
++PLS
Oct 8 '07 #1
3 2438
On Oct 9, 8:28 am, PLS <nob...@nowhere.comwrote:
I don't know exactly how to use VB.

Generally, we can use like this.

protected int ID
{
get
{
return _customerID;
}

public set
{
_customerID = value;
}
}

VB.NET allows defining a property that has different get and set types
by doing this
Public Property fFlag(ByVal flag as flagEnumeration) As Boolean
Get
Return ...
End Get
Set(ByBal Value as Boolean)
...
End Set
End Property

What is the C# equivalent of this?

Thanks,
++PLS

Oct 9 '07 #2
PLS wrote:
VB.NET allows defining a property that has different get and set types
by doing this
Public Property fFlag(ByVal flag as flagEnumeration) As Boolean
Get
Return ...
End Get
Set(ByBal Value as Boolean)
...
End Set
End Property

What is the C# equivalent of this?
I'm not really clear on what behavior you're looking for here. The code
you posted has a Boolean property, that returns a Boolean and has a
setter than takes a Boolean as a parameter.

So, I don't see how the property defined in the code you posted "has
different get and set types".

Now, that said, a C# property cannot have a parameter list as the
property you've posted does. You can have an indexer, which is like a
property that takes one or more parameters, and which looks a lot like
an array syntax-wise.

Maybe that's the kind of behavior you're trying to achieve?

http://msdn2.microsoft.com/en-us/library/6x16t2tx.aspx

Note that there can be only one indexer for a class. You can't define
an arbitrarily-named property that takes parameters.

Pete
Oct 9 '07 #3
PLS,

Do you know the sence of this, I don't see the reason at all.

VB.Net would in my opinion be better of by just following the type of the
member.
I have never used this.

I am glad this in my opinion not fine behaviour of VB (although it has
something more then C#) is not in C#.

However as Peter, I am currious why you want this.

(It is not optional in VB.Net and although properties are automaticly build
in VB.Net you see it forever in your code).

Cor

Oct 9 '07 #4

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

Similar topics

2
by: Jon Slaughter | last post by:
Lets assume I want to write a whole host of classes having "property" elements in them and create a bunch of objects from the different classes. Lets suppose that they are circles, lines, etc......
8
by: deko | last post by:
I'm trying to find a way to set form/control properties programmatically. In a nut shell: 1. Open a database 2. Open a form in design view 3. Do something like this: For Each prp In...
24
by: downwitch | last post by:
Hi, I know this has been covered here and in the .public groups, but it seems like it's been a while, especially around here, so I just thought I'd ask again to see if anyone has figured out a...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
3
by: jralford | last post by:
Hi, I have a main form with a number of controls on it. They are a range of different customized controls. There are some properties that belong to all of these controls, such as XOffset,...
3
by: M Shafaat | last post by:
Hi! I want to make a base class with some base properties and then derive different other classes from that in which I want to override the base properties to get specialized behaviour unique for...
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
4
by: beatdream | last post by:
I am designing a database to handle different kinds of products ... and these products can have different properties...for example, a trouser can be specified by the width, length, color, and other...
10
by: Timothy | last post by:
Hi, I was looking over some differences between C# and VB code today and noticed that the set method in properties act completely different. C# values are passed by reference, and VB values are...
17
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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,...
0
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...

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.