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

C#

 
GeneralRe: string concatenation: several seconds Pin
BobJanova2-Dec-11 5:49
BobJanova2-Dec-11 5:49 
GeneralRe: string concatenation: several seconds Pin
Rob Philpott2-Dec-11 5:55
Rob Philpott2-Dec-11 5:55 
GeneralRe: string concatenation: several seconds Pin
BobJanova2-Dec-11 6:05
BobJanova2-Dec-11 6:05 
GeneralRe: string concatenation: several seconds Pin
Not Active2-Dec-11 3:01
mentorNot Active2-Dec-11 3:01 
GeneralRe: string concatenation: several seconds Pin
pirotrav2-Dec-11 3:13
pirotrav2-Dec-11 3:13 
GeneralRe: string concatenation: several seconds Pin
Not Active2-Dec-11 4:04
mentorNot Active2-Dec-11 4:04 
AnswerRe: string concatenation: several seconds Pin
emardini2-Dec-11 3:34
emardini2-Dec-11 3:34 
GeneralRe: string concatenation: several seconds Pin
pirotrav2-Dec-11 21:03
pirotrav2-Dec-11 21:03 
Emardini,

Tried your code. Worked like a dream. That said, this part of the program was borrowed from the link above, so I never really understood it in the first place. I have gone from several minute sorts to < 1 second.


C#
  Func<string, object> convert = str =>
  {
      try { return int.Parse(str); }
      catch { return str; }
 };//My function (one borrowed from link above)

Func<string, object> convert = str =>
{
    int value = 0;
    return int.TryParse(str, out value) ? (object)value : str;
};//Emardini's function that works 'properly', i.e fast


Emardini, or anyone else. Can you break this down and explain what the difference/ meaning of both functions is? I know that sounds silly since it's from my program, but this project is merely to polish up on what I learned in previous semesters, complete a mundane task, and learn as much as possible along the way.

Edit:Having looked at this a bit more, if I understand right 'out' vs 'return' is the key difference. Still not entirely sure on what that means in the context of the above code.

modified 3-Dec-11 3:15am.

GeneralRe: string concatenation: several seconds Pin
Gerry Schmitz2-Dec-11 22:23
mveGerry Schmitz2-Dec-11 22:23 
GeneralRe: string concatenation: several seconds Pin
pirotrav3-Dec-11 19:26
pirotrav3-Dec-11 19:26 
AnswerRe: string concatenation: several seconds Pin
PIEBALDconsult2-Dec-11 3:48
mvePIEBALDconsult2-Dec-11 3:48 
AnswerRe: string concatenation: several seconds Pin
OriginalGriff2-Dec-11 4:14
mveOriginalGriff2-Dec-11 4:14 
QuestionRe: string concatenation: several seconds Pin
Luc Pattyn2-Dec-11 4:57
sitebuilderLuc Pattyn2-Dec-11 4:57 
AnswerRe: string concatenation: several seconds Pin
OriginalGriff2-Dec-11 5:56
mveOriginalGriff2-Dec-11 5:56 
AnswerRe: string concatenation: several seconds Pin
BobJanova2-Dec-11 6:15
BobJanova2-Dec-11 6:15 
AnswerRe: string concatenation: several seconds Pin
Rick Bassham2-Dec-11 6:16
Rick Bassham2-Dec-11 6:16 
AnswerRe: string concatenation: several seconds Pin
#realJSOP2-Dec-11 7:10
mve#realJSOP2-Dec-11 7:10 
GeneralRe: string concatenation: several seconds Pin
phil.o2-Dec-11 8:46
professionalphil.o2-Dec-11 8:46 
AnswerRe: string concatenation: several seconds Pin
Eddy Vluggen2-Dec-11 7:27
professionalEddy Vluggen2-Dec-11 7:27 
AnswerRe: string concatenation: several seconds Pin
BillWoodruff2-Dec-11 20:11
professionalBillWoodruff2-Dec-11 20:11 
QuestionChanging ForeColor Item in ListBox ... Pin
nassimnastaran2-Dec-11 0:41
nassimnastaran2-Dec-11 0:41 
AnswerRe: Changing ForeColor Item in ListBox ... Pin
Dan Mos2-Dec-11 1:03
Dan Mos2-Dec-11 1:03 
AnswerRe: Changing ForeColor Item in ListBox ... PinPopular
Alan N2-Dec-11 1:49
Alan N2-Dec-11 1:49 
GeneralRe: Changing ForeColor Item in ListBox ... Pin
Dan Mos2-Dec-11 1:55
Dan Mos2-Dec-11 1:55 
GeneralRe: Changing ForeColor Item in ListBox ... Pin
Wonde Tadesse2-Dec-11 17:05
professionalWonde Tadesse2-Dec-11 17:05 

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.