Does C# have the ability to define array properties, as in Delphi? For
example, does the following have an equivalent in C#?
type
TMyGrid = class
{ ...some code... }
property IntegerCells[i, j: Integer]: Integer read GetIntegerCell write
SetIntegerCell;
property StringCells[i, j: Integer]: Integer read GetStringCell write
SetStringCell;
{ ...some code... }
end; 3 1806
No, you can only do this for indexers, but not for properties. This is a
real annoyance in C# (you can do it in VB.NET, so why not in C# is anybody's
guess).
"Debbie Croft" <de**********@nospamforme.comwrote in message
news:13*************@corp.supernews.com...
Does C# have the ability to define array properties, as in Delphi? For
example, does the following have an equivalent in C#?
type
TMyGrid = class
{ ...some code... }
property IntegerCells[i, j: Integer]: Integer read GetIntegerCell write
SetIntegerCell;
property StringCells[i, j: Integer]: Integer read GetStringCell write
SetStringCell;
{ ...some code... }
end;
On Jul 19, 3:48 am, "Clive Dixon" <clived at digita dot comwrote:
No, you can only do this for indexers, but not for properties. This is a
real annoyance in C# (you can do it in VB.NET, so why not in C# is anybody's
guess).
"Debbie Croft" <debbie.cr...@nospamforme.comwrote in message
news:13*************@corp.supernews.com...
Does C# have the ability to define array properties, as in Delphi? For
example, does the following have an equivalent in C#?
type
TMyGrid = class
{ ...some code... }
property IntegerCells[i, j: Integer]: Integer read GetIntegerCell write
SetIntegerCell;
property StringCells[i, j: Integer]: Integer read GetStringCell write
SetStringCell;
{ ...some code... }
end;
Yes, but you can have a property that is a 2 dimensional array:
private int[,] _myArray;
public int[,] MyArray {
get { return _myArray; }
set { _myArray = value; }
}
Then initialize it and use it with this code:
this.MyArray = new int[10,10];
this.MyArray[5,5] = 25;
Chris
"Chris Dunaway" <du******@gmail.comwrote:
Yes, but you can have a property that is a 2 dimensional array:
private int[,] _myArray;
public int[,] MyArray {
get { return _myArray; }
set { _myArray = value; }
}
Not very safe when one caller might completely replace the array that
another one wrote to!
Eq. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: exitus |
last post by:
Is there a way to dynamically resize an array along with maintaining
its contents similar to VB's REDIM PRESERVE statement in C#? My
problem is, the user won't be sure how big the string array...
|
by: BuddyWork |
last post by:
Hello,
Sorry I posted this message in the newsgroup, as I could
not find an IIS group.
I'm running Windows XP Professional and when I try to
display the Properties dialog by pressing right...
|
by: benben |
last post by:
Recently I have come across a number of struct's that I think is quite
interesting:
typedef struct whatever_tag
{
int member1;
char member2;
// ...
char last_member; // interesting line
|
by: jose.cortijo |
last post by:
Hi everybody,
I would like to access to one variable by an indirect mode. I would try
to explain myself:
I have like twelve variables and all of them are global scope.
The point is that I...
|
by: Mythran |
last post by:
How can I set a DefaultValue for an array property? I don't have a project
that uses this anymore, but still am curious. Of all the replies I've
posted here, a simple thing like this is my...
|
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4. Is there a shorter way to check if an array has
an element besides doing a for loop and iterating through each element?
Thanks, - Dave
|
by: Velislav |
last post by:
Hi, I've got the following piece of code:
string GetPropertyValue(object jobCard, string propertyName,
int index)
{
PropertyInfo property =
jobCard.GetType().GetProperty(propertyName);
if...
|
by: Rick Giuly |
last post by:
Hello All,
Case 1
This generates an error, which makes sense because the argument should
be a list of numbers:
numpy.array(10,10)
Case 2
This does not generate an error and the result is an...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |