Click here to Skip to main content
15,888,802 members
Home / Discussions / C#
   

C#

 
AnswerRe: Image Upload and Resize Pin
OriginalGriff16-Dec-10 22:16
mveOriginalGriff16-Dec-10 22:16 
JokeRe: Image Upload and Resize [modified] Pin
_Erik_17-Dec-10 3:21
_Erik_17-Dec-10 3:21 
QuestionEnumeration as Indexer: Is C# not the strongly-typed? Pin
Paul Selormey16-Dec-10 20:07
Paul Selormey16-Dec-10 20:07 
AnswerRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
harold aptroot16-Dec-10 21:58
harold aptroot16-Dec-10 21:58 
GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
Paul Selormey16-Dec-10 23:40
Paul Selormey16-Dec-10 23:40 
AnswerRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
Eddy Vluggen16-Dec-10 22:06
professionalEddy Vluggen16-Dec-10 22:06 
GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? [modified] Pin
Paul Selormey16-Dec-10 23:26
Paul Selormey16-Dec-10 23:26 
GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
Eddy Vluggen17-Dec-10 0:38
professionalEddy Vluggen17-Dec-10 0:38 
Paul Selormey wrote:
so the AFormat testFormat = collFormats[0]; is asking for the zero-indexed item.

Ask your debugger;
C#
for (int i = 0; i < this.Count; i++)
{
    AFormat format = base[i];
    if (format.FormatType == type)
    {
        return format;
    }
}

return null;

Your indexer-implementation doesn't return anything based on index, it's returning the item that has the specified enumvalue. The debugger will loop through the collection, compare the type parameter from your indexer to the FormatType property. Since there's no item in the collection with a enumvalue None, null is returned.

It's not going to take the 0 as a hint that it should use the inherited indexer, it'll simply convert your 0 into the enums value for (int)0 and use the indexer that's specified for the enum.
I are Troll Suspicious | :suss:

GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
Paul Selormey17-Dec-10 0:48
Paul Selormey17-Dec-10 0:48 
GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
harold aptroot17-Dec-10 1:13
harold aptroot17-Dec-10 1:13 
GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
Paul Selormey17-Dec-10 1:19
Paul Selormey17-Dec-10 1:19 
GeneralRe: Enumeration as Indexer: Is C# not the strongly-typed? Pin
Eddy Vluggen17-Dec-10 1:49
professionalEddy Vluggen17-Dec-10 1:49 
QuestionWhat's the purpose to use Property with set and get to change a field? Pin
nstk16-Dec-10 19:29
nstk16-Dec-10 19:29 
AnswerRe: What's the purpose to use Property with set and get to change a field? Pin
JF201516-Dec-10 20:02
JF201516-Dec-10 20:02 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
nstk16-Dec-10 23:01
nstk16-Dec-10 23:01 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 6:09
Jeff Connelly17-Dec-10 6:09 
AnswerRe: What's the purpose to use Property with set and get to change a field? Pin
Hiren solanki16-Dec-10 23:52
Hiren solanki16-Dec-10 23:52 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 6:15
Jeff Connelly17-Dec-10 6:15 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
PIEBALDconsult17-Dec-10 7:50
mvePIEBALDconsult17-Dec-10 7:50 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
kevinnicol17-Dec-10 7:53
kevinnicol17-Dec-10 7:53 
GeneralRe: What's the purpose to use Property with set and get to change a field? [modified] Pin
Jeff Connelly17-Dec-10 8:21
Jeff Connelly17-Dec-10 8:21 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
kevinnicol17-Dec-10 8:23
kevinnicol17-Dec-10 8:23 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 8:39
Jeff Connelly17-Dec-10 8:39 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
kevinnicol17-Dec-10 8:47
kevinnicol17-Dec-10 8:47 
GeneralRe: What's the purpose to use Property with set and get to change a field? Pin
Jeff Connelly17-Dec-10 8:50
Jeff Connelly17-Dec-10 8:50 

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.