Click here to Skip to main content
15,881,630 members
Home / Discussions / C#
   

C#

 
AnswerRe: Tuples in Functions Pin
Ravi Bhavnani17-Aug-12 4:39
professionalRavi Bhavnani17-Aug-12 4:39 
AnswerRe: Tuples in Functions Pin
DaveyM6917-Aug-12 22:21
professionalDaveyM6917-Aug-12 22:21 
GeneralRe: Tuples in Functions Pin
BillWoodruff18-Aug-12 7:17
professionalBillWoodruff18-Aug-12 7:17 
GeneralRe: Tuples in Functions Pin
DaveyM6918-Aug-12 8:09
professionalDaveyM6918-Aug-12 8:09 
AnswerRe: Tuples in Functions Pin
WebMaster18-Aug-12 5:20
WebMaster18-Aug-12 5:20 
GeneralRe: Tuples in Functions Pin
DaveyM6918-Aug-12 8:15
professionalDaveyM6918-Aug-12 8:15 
GeneralRe: Tuples in Functions Pin
WebMaster18-Aug-12 9:53
WebMaster18-Aug-12 9:53 
AnswerRe: Tuples in Functions Pin
Keith Barrow18-Aug-12 9:38
professionalKeith Barrow18-Aug-12 9:38 
OK, I realise I suggested the Tuple thing in the thread below. What you have will work (when fixed) and is arguably correct. However if the return value "means" something as a pair it would be better in a language like C# creating a class or struct to contain them. One rule of thumb is if you can give your return "thing" a sensible name. Let's say for the sake of argument the return values represent a x/y co-ordinate pair. If this were the case then you'd be better of creating a class or struct. If the values are really two results from a calculation (as you have in your example) a tuple is good. The point of the class is that it gives semantic meaning to your program, which developers that follow you can understand.

[Edit]
This came to me after reading Bill's reply below. One thing that you also need to consider with the tuple is that it is reliant on the code consuming the class knowing what order the values were put in (and your code putting them in the right order), if you were returning say a string and a double there would be less problem. That said creating a container class or struct the values would be explicitly named, reducing the potential for error.

Hopefully this isn't too confusing, getting to grips with programming is quite a task. This is a good read[^] if you are just starting out, it isn't as negative as the first few paragraphs suggest.


modified 18-Aug-12 16:35pm.

AnswerRe: Tuples in Functions Pin
BillWoodruff18-Aug-12 9:43
professionalBillWoodruff18-Aug-12 9:43 
GeneralMy Vote of 5 Pin
Keith Barrow18-Aug-12 10:32
professionalKeith Barrow18-Aug-12 10:32 
GeneralRe: Tuples in Functions Pin
leppie18-Aug-12 21:37
leppie18-Aug-12 21:37 
GeneralRe: Tuples in Functions Pin
BillWoodruff19-Aug-12 14:15
professionalBillWoodruff19-Aug-12 14:15 
GeneralRe: Tuples in Functions Pin
leppie19-Aug-12 19:41
leppie19-Aug-12 19:41 
AnswerLeppie's interesting suggestion to use 'Anonymous Classes' ... Re: Tuples in Functions Pin
BillWoodruff18-Aug-12 15:49
professionalBillWoodruff18-Aug-12 15:49 
GeneralRe: Leppie's interesting suggestion to use 'Anonymous Classes' ... Re: Tuples in Functions Pin
BobJanova20-Aug-12 1:00
BobJanova20-Aug-12 1:00 
QuestionTrying to Obtain Two (2) Values from Function Pin
computerpublic16-Aug-12 21:53
computerpublic16-Aug-12 21:53 
AnswerRe: Trying to Obtain Two (2) Values from Function Pin
DaveyM6916-Aug-12 22:36
professionalDaveyM6916-Aug-12 22:36 
GeneralRe: Trying to Obtain Two (2) Values from Function Pin
BobJanova16-Aug-12 22:54
BobJanova16-Aug-12 22:54 
GeneralRe: Trying to Obtain Two (2) Values from Function Pin
Keith Barrow17-Aug-12 2:12
professionalKeith Barrow17-Aug-12 2:12 
AnswerRe: Trying to Obtain Two (2) Values from Function Pin
Sangramsingh Pawar17-Aug-12 0:43
Sangramsingh Pawar17-Aug-12 0:43 
AnswerRe: Trying to Obtain Two (2) Values from Function Pin
V.17-Aug-12 3:16
professionalV.17-Aug-12 3:16 
AnswerRe: Trying to Obtain Two (2) Values from Function Pin
Kuthuparakkal17-Aug-12 16:05
Kuthuparakkal17-Aug-12 16:05 
QuestionHow to insert,update and edit data in datagridview window form Pin
ope4sure116-Aug-12 19:54
ope4sure116-Aug-12 19:54 
AnswerRe: How to insert,update and edit data in datagridview window form Pin
Calla16-Aug-12 20:53
Calla16-Aug-12 20:53 
GeneralRe: How to insert,update and edit data in datagridview window form Pin
Dave Kreskowiak17-Aug-12 3:37
mveDave Kreskowiak17-Aug-12 3:37 

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.