Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
GeneralRe: While MouseDown Pin
Zap-Man17-Oct-09 5:46
Zap-Man17-Oct-09 5:46 
GeneralRe: While MouseDown Pin
Not Active17-Oct-09 6:15
mentorNot Active17-Oct-09 6:15 
AnswerRe: While MouseDown Pin
dojohansen18-Oct-09 0:49
dojohansen18-Oct-09 0:49 
QuestionOwner drawn TabControl doesn't act as I want it Pin
WebMaster17-Oct-09 0:20
WebMaster17-Oct-09 0:20 
AnswerRe: Owner drawn TabControl doesn't act as I want it Pin
WebMaster17-Oct-09 21:28
WebMaster17-Oct-09 21:28 
GeneralRe: Owner drawn TabControl doesn't act as I want it Pin
Dave Kreskowiak18-Oct-09 2:33
mveDave Kreskowiak18-Oct-09 2:33 
QuestionIndexing a property that returns an array. [modified] Pin
CaptainSeeSharp16-Oct-09 17:15
CaptainSeeSharp16-Oct-09 17:15 
AnswerRe: Indexing a property that returns an array. [modified] Pin
Luc Pattyn16-Oct-09 17:49
sitebuilderLuc Pattyn16-Oct-09 17:49 
Hi,

the statement a = TheArray[0]; contains three operations:
1. getting an array (TheArray)
2. getting an element (TheArray[0])
3. assigning a value (to a)

the statement TheArray[1]=255; contains three operations:
1. evaluating an expression (255)
2. getting an array (TheArray)
3. setting an element (TheArray[1])

So in both cases it is the array getter that is used, that is why it works.
An array setter property would be used to assign a new array, as in TheArray=new byte[] {1,2,3,4};

If you want a property that works on a specific array element, then:
- the type should be byte, not byte[], as only one element will be operated upon
- the index must be known somehow (by being fixed, or as a parameter); when a parameter is required it no longer is a property, it becomes a method as in byte GetArrayElementAt(int index) or SetArratElementAt(int index, byte val)

There is a way to use an indexer, however that is not a general solution, as it doesn't have an identifier (it uses "this" to refer to the class), see here[^]; so for an int indexer, you can only do it once on a class (however, you can do another indexer with say a string index).

Smile | :)

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages

Local announcement (Antwerp region): Lange Wapper? Neen!


modified on Friday, October 16, 2009 11:55 PM

AnswerRe: Indexing a property that returns an array. Pin
dojohansen18-Oct-09 0:59
dojohansen18-Oct-09 0:59 
QuestionCouple of questions regarding Windows Service in C# Pin
Aryan S16-Oct-09 17:14
Aryan S16-Oct-09 17:14 
AnswerRe: Couple of questions regarding Windows Service in C# Pin
Dave Kreskowiak16-Oct-09 18:22
mveDave Kreskowiak16-Oct-09 18:22 
AnswerRe: Couple of questions regarding Windows Service in C# Pin
PIEBALDconsult17-Oct-09 5:40
mvePIEBALDconsult17-Oct-09 5:40 
QuestionForm flickering problem Pin
SimpleData16-Oct-09 9:55
SimpleData16-Oct-09 9:55 
AnswerRe: Form flickering problem Pin
Luc Pattyn16-Oct-09 10:25
sitebuilderLuc Pattyn16-Oct-09 10:25 
GeneralRe: Form flickering problem Pin
SimpleData16-Oct-09 11:24
SimpleData16-Oct-09 11:24 
GeneralRe: Form flickering problem Pin
Luc Pattyn16-Oct-09 12:40
sitebuilderLuc Pattyn16-Oct-09 12:40 
GeneralRe: Form flickering problem Pin
SimpleData16-Oct-09 23:19
SimpleData16-Oct-09 23:19 
GeneralRe: Form flickering problem Pin
Luc Pattyn17-Oct-09 2:18
sitebuilderLuc Pattyn17-Oct-09 2:18 
GeneralRe: Form flickering problem Pin
Lyon Sun17-Oct-09 4:14
Lyon Sun17-Oct-09 4:14 
GeneralRe: Form flickering problem Pin
Luc Pattyn17-Oct-09 4:18
sitebuilderLuc Pattyn17-Oct-09 4:18 
GeneralRe: Form flickering problem Pin
Lyon Sun17-Oct-09 8:09
Lyon Sun17-Oct-09 8:09 
GeneralRe: Form flickering problem Pin
Luc Pattyn17-Oct-09 8:35
sitebuilderLuc Pattyn17-Oct-09 8:35 
GeneralRe: Form flickering problem Pin
Lyon Sun17-Oct-09 10:27
Lyon Sun17-Oct-09 10:27 
QuestionFill Collection With Excel Sheet Column Names Pin
Kevin Marois16-Oct-09 7:14
professionalKevin Marois16-Oct-09 7:14 
AnswerRe: Fill Collection With Excel Sheet Column Names Pin
dan!sh 16-Oct-09 7:32
professional dan!sh 16-Oct-09 7:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.