Click here to Skip to main content
15,936,677 members
Home / Discussions / C#
   

C#

 
GeneralRe: questions about an array? Pin
Keith Barrow18-Sep-09 5:15
professionalKeith Barrow18-Sep-09 5:15 
GeneralRe: questions about an array? Pin
harold aptroot18-Sep-09 5:26
harold aptroot18-Sep-09 5:26 
GeneralTerinary commands then what is wrong with this example? As I am learning to use them... Pin
JollyMansArt18-Sep-09 5:41
JollyMansArt18-Sep-09 5:41 
GeneralRe: Terinary commands then what is wrong with this example? As I am learning to use them... Pin
harold aptroot18-Sep-09 5:47
harold aptroot18-Sep-09 5:47 
GeneralRe: Terinary commands then what is wrong with this example? As I am learning to use them... Pin
JollyMansArt18-Sep-09 5:55
JollyMansArt18-Sep-09 5:55 
GeneralRe: Terinary commands then what is wrong with this example? As I am learning to use them... Pin
JollyMansArt18-Sep-09 6:11
JollyMansArt18-Sep-09 6:11 
GeneralRe: Terinary commands then what is wrong with this example? As I am learning to use them... Pin
JollyMansArt18-Sep-09 5:52
JollyMansArt18-Sep-09 5:52 
GeneralRe: questions about an array? Pin
Keith Barrow18-Sep-09 6:24
professionalKeith Barrow18-Sep-09 6:24 
Pure Laziness.
int x = -1;
if(DynamicArray != null)  
   x = DynamicArray.Length;



Is shorter than

int x;
if(DynamicArray == null)  
   x = -1;
else
   x = DynamicArray.Length;



When I started to reply, no-one had (at that point) explained what the ternary operator did, I wasn't trying to make a point that my OP was better or more accurate or anything, someone just beat me to the punch. If I had to implement the length property , and it needed to return -1 in the manner requested in the top post I'd actually do it like this:
public const int UninitializedLength = -1;

public int Length 
{
    get
    {
      if(DynamicArray == null)
        return UninitializedLength;
      return DynamicArray.Length;
    }
}

GeneralRe: questions about an array? Pin
Richard MacCutchan18-Sep-09 5:02
mveRichard MacCutchan18-Sep-09 5:02 
GeneralRe: questions about an array? Pin
JollyMansArt18-Sep-09 4:42
JollyMansArt18-Sep-09 4:42 
GeneralRe: questions about an array? Pin
harold aptroot18-Sep-09 4:49
harold aptroot18-Sep-09 4:49 
JokeRe: questions about an array? Pin
JollyMansArt18-Sep-09 4:53
JollyMansArt18-Sep-09 4:53 
AnswerRe: questions about an array? Pin
JollyMansArt18-Sep-09 4:29
JollyMansArt18-Sep-09 4:29 
AnswerRe: questions about an array? [modified] Pin
Keith Barrow18-Sep-09 4:32
professionalKeith Barrow18-Sep-09 4:32 
JokeRe: questions about an array? Pin
JollyMansArt18-Sep-09 4:50
JollyMansArt18-Sep-09 4:50 
GeneralRe: questions about an array? Pin
Keith Barrow18-Sep-09 4:59
professionalKeith Barrow18-Sep-09 4:59 
AnswerRe: questions about an array? Pin
dan!sh 18-Sep-09 4:37
professional dan!sh 18-Sep-09 4:37 
GeneralRe: questions about an array? Pin
JollyMansArt18-Sep-09 4:51
JollyMansArt18-Sep-09 4:51 
Questiongetfilename Pin
kennyhibs18-Sep-09 3:58
kennyhibs18-Sep-09 3:58 
AnswerRe: getfilename Pin
Wes Aday18-Sep-09 4:14
professionalWes Aday18-Sep-09 4:14 
GeneralRe: getfilename Pin
kennyhibs18-Sep-09 4:27
kennyhibs18-Sep-09 4:27 
GeneralRe: getfilename Pin
Wes Aday18-Sep-09 4:43
professionalWes Aday18-Sep-09 4:43 
AnswerRe: getfilename Pin
OriginalGriff18-Sep-09 4:18
mveOriginalGriff18-Sep-09 4:18 
QuestionCreatin Combo lists using an App Config file Pin
TheFoZ18-Sep-09 3:33
TheFoZ18-Sep-09 3:33 
AnswerRe: Creatin Combo lists using an App Config file Pin
Atul Kharecha18-Sep-09 3:45
Atul Kharecha18-Sep-09 3:45 

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.