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

C#

 
GeneralRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
User9874316-Mar-18 2:59
professionalUser9874316-Mar-18 2:59 
AnswerRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
Eddy Vluggen21-Feb-18 3:03
professionalEddy Vluggen21-Feb-18 3:03 
GeneralRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
User9874316-Mar-18 3:01
professionalUser9874316-Mar-18 3:01 
GeneralRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
Eddy Vluggen16-Mar-18 7:13
professionalEddy Vluggen16-Mar-18 7:13 
AnswerRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
V.21-Feb-18 21:26
professionalV.21-Feb-18 21:26 
GeneralRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
User9874316-Mar-18 3:03
professionalUser9874316-Mar-18 3:03 
GeneralRe: Is it ok NOT to pass fields into the methods in the same class as parameters? Pin
V.16-Mar-18 3:42
professionalV.16-Mar-18 3:42 
Questionan interesting aspect of C# 7 extended Tuple semantics Pin
BillWoodruff20-Feb-18 2:11
professionalBillWoodruff20-Feb-18 2:11 
A recent comment by OriginalGriff [^] reminded me of the fact that this:
private (string, int, string) getstuff()
{ 
    return (S1: "boo", I1: 99, S2: "ddd");
}
when called: the result will not expose the field Names you specified in the ValueTuple declaration: any attempt to use those Names will not compile. But, this:
private (String S1, int I1, string S2) getstuff()
{ 
    return ("boo", 99, "ddd");
}
when called,: compiles, and the result exposes the Names. Of course, you can specify Names at any time:
String xS1, int xI1, string xS2) stuff1 = GetStuff(); independently of whatever "format" the source ValueTuple is in.

This leads me to the hypothesis that internal specification of ValueTuple field Names is probably redundant if said ValueTuple is returned from the Class. Of course, that is not to say that defining the Names internally is not useful ... if those Names are used internally.

It also suggests, to me, that if a ValueTuple is being passed around, every consumer must declare those Names to keep them "fresh" (of course, use of 'dynamic is ignored here).

But, where does this lead you ?

Would you consider using a Property like :
public (string S1, int I1, string S2) VTProp {set; get;}
To make sure the field Names stayed "fresh" even when it has its value set without field Names: VTProp = ("hello", 23, "exit"); ?
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12

AnswerRe: an interesting aspect of C# 7 extended Tuple semantics Pin
Richard Deeming20-Feb-18 2:32
mveRichard Deeming20-Feb-18 2:32 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
BillWoodruff20-Feb-18 4:23
professionalBillWoodruff20-Feb-18 4:23 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
Richard Deeming20-Feb-18 4:29
mveRichard Deeming20-Feb-18 4:29 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
BillWoodruff20-Feb-18 6:29
professionalBillWoodruff20-Feb-18 6:29 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
Richard Deeming20-Feb-18 6:43
mveRichard Deeming20-Feb-18 6:43 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
BillWoodruff20-Feb-18 16:17
professionalBillWoodruff20-Feb-18 16:17 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
Richard Deeming21-Feb-18 7:50
mveRichard Deeming21-Feb-18 7:50 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
BillWoodruff22-Feb-18 4:13
professionalBillWoodruff22-Feb-18 4:13 
GeneralRe: an interesting aspect of C# 7 extended Tuple semantics Pin
Richard Deeming22-Feb-18 7:49
mveRichard Deeming22-Feb-18 7:49 
Questionhow to delete a question? Pin
Member 1368582120-Feb-18 1:27
Member 1368582120-Feb-18 1:27 
AnswerRe: How to make Data Recovery Software using C# Pin
Maciej Los20-Feb-18 3:02
mveMaciej Los20-Feb-18 3:02 
GeneralMessage Closed Pin
20-Feb-18 9:17
Member 1368582120-Feb-18 9:17 
GeneralRe: How to make Data Recovery Software using C# Pin
Richard Andrew x6420-Feb-18 10:04
professionalRichard Andrew x6420-Feb-18 10:04 
GeneralRe: How to make Data Recovery Software using C# Pin
phil.o20-Feb-18 12:49
professionalphil.o20-Feb-18 12:49 
AnswerRe: How to make Data Recovery Software using C# Pin
Gerry Schmitz20-Feb-18 10:45
mveGerry Schmitz20-Feb-18 10:45 
AnswerRe: How to make Data Recovery Software using C# Pin
Dave Kreskowiak20-Feb-18 13:50
mveDave Kreskowiak20-Feb-18 13:50 
AnswerRe: How to make Data Recovery Software using C# Pin
MadMyche22-Feb-18 4:44
professionalMadMyche22-Feb-18 4:44 

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.