Classes should have private fields, and they should be accessed
through properties. But what if the field is an array? I know you
can use an indexer to use [] syntax on the entire class itself, but
what about using the [] syntax for a property that hides a field that
is an array?
Is this possible? I was pretty sure it was in VB, but I must be
mistaken, since I don't see it in C#. I am surprised if it is not
possible, since you'd have to code a method to make accessors for
array fields.
Zytan 4 1507
On Mar 21, 2:51 pm, "Zytan" <zytanlith...@yahoo.comwrote:
Classes should have private fields, and they should be accessed
through properties. But what if the field is an array? I know you
can use an indexer to use [] syntax on the entire class itself, but
what about using the [] syntax for a property that hides a field that
is an array?
Is this possible? I was pretty sure it was in VB, but I must be
mistaken, since I don't see it in C#. I am surprised if it is not
possible, since you'd have to code a method to make accessors for
array fields.
No, C# doesn't have named indexers, which I think is what you mean.
Yes, it's a bit of a pain.
Jon
No, C# doesn't have named indexers, which I think is what you mean.
Yes, it's a bit of a pain.
Yes, that's just what I mean. Indeed it is a pain. Surprising that VB
has it and C# doesn't.
Thanks for the confirmation.
Zytan
Zytan wrote:
No, C# doesn't have named indexers, which I think is what you mean.
Yes, it's a bit of a pain.
Yes, that's just what I mean. Indeed it is a pain. Surprising that VB
has it and C# doesn't.
You can fake it by creating or using a class which is itself indexable,
and exposing it as a property. E.g. see Collection<T>.
-- Barry
-- http://barrkel.blogspot.com/
You can fake it by creating or using a class which is itself indexable,
and exposing it as a property. E.g. see Collection<T>.
Yes, that's true, thanks, Barry.
Zytan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Perttu Pulkkinen |
last post by:
Hi all php freaks!
Do you think this kind of "property class" is useful or not? I have bee
bored to the way I've been coding earlier. because:
- often i have database-oriented classes like...
|
by: Tom Paquette |
last post by:
Hi,
Having made very good use of the ADO recordset Field indexes created by
setting the Optimize property, I am thrashing through ADO.Net literature to
identify the same functionality. Being...
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have...
|
by: Jon Maz |
last post by:
Hi All,
I'm reasonably proficient with C#, and am starting with php5. I was happy
to learn of the __get and __set methods, but am encountering a problem using
them to set an object property of...
|
by: Vladimir |
last post by:
Hello,
I have a table in MS Access database. It has one field (with BYTE datatype)
that has several properties set in Lookup tab of table Design View.
Display Control = Combo Box. Row Source...
|
by: Thomas Solh?j |
last post by:
Hi all.
I cant databind rtf values to the rtf property of a winform
richtextbox control. Does something have a clue how this i done?
Ive tried this without luck:...
|
by: Saurabh |
last post by:
Hi Gurus,
We are in the process of writing a code in C# and have to use a dll written
in VB through interop and have come across an issue; In one of our other
development projects in Visual...
|
by: wASP |
last post by:
Hi,
I've got a pair of int properties in a class.
The properties in question are indexing values
- but that's not relevant to my problem
- or it's just symptomatic ... sort of.
They are...
|
by: Q |
last post by:
Hello to the pro's,
I want to use an array in a class. This array should be visible as a
property.
Just can't seem to find out how to do it.
Maybe there are other (and more easy) solutions?...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |