Click here to Skip to main content
15,896,912 members
Home / Discussions / C#
   

C#

 
AnswerRe: behavior of Value Tuples in .NET 4.7 Pin
Eddy Vluggen19-Jun-17 21:55
professionalEddy Vluggen19-Jun-17 21:55 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
BillWoodruff20-Jun-17 6:34
professionalBillWoodruff20-Jun-17 6:34 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
Eddy Vluggen20-Jun-17 8:37
professionalEddy Vluggen20-Jun-17 8:37 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
BillWoodruff20-Jun-17 15:39
professionalBillWoodruff20-Jun-17 15:39 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
Eddy Vluggen21-Jun-17 3:45
professionalEddy Vluggen21-Jun-17 3:45 
AnswerRe: behavior of Value Tuples in .NET 4.7 Pin
Bernhard Hiller19-Jun-17 22:46
Bernhard Hiller19-Jun-17 22:46 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
BillWoodruff20-Jun-17 6:44
professionalBillWoodruff20-Jun-17 6:44 
AnswerRe: behavior of Value Tuples in .NET 4.7 Pin
Richard Deeming20-Jun-17 0:50
mveRichard Deeming20-Jun-17 0:50 
I can possibly see them being useful internally within a single project. But for shared code, a traditional class or struct would still be the better option.

Code, code and more code.: Exploring Tuples as a Library Author[^]
C# 7: Dynamic types and Reflection cannot access Tuple fields by name[^]
C# 7 ValueTuple types and their limitations | Joseph Woodward, Software Developer[^]


NB: Your example won't compile. You're missing the types for the middle and last constructor arguments, and the FullName property doesn't have a setter.
C#
public Name(string first = null, string middle = null, string last = null) { ... }
...
public (string first, string middle, string last) FullName
{
    get 
    {
        return (first: FirstName, middle: MiddleName, last: LastName); 
    }
    set 
    { 
        FirstName = value.first;
        MiddleName = value.middle;
        LastName = value.last;
        
        // Or:
        // (FirstName, MiddleName, LastName) = value; 
    }
}

You'd probably also want to declare a deconstructor on the class:
C#
public void Deconstruct(out string first, out string middle, out string last)
{
    first = FirstName;
    middle = MiddleName;
    last = LastName;
}

That would let you pick out parts of the class:
C#
var (_, _, lastname) = nametest2;
// lastname == "doe"

c sharp7 deconstruction demystified · Surfing the code[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
BillWoodruff20-Jun-17 6:50
professionalBillWoodruff20-Jun-17 6:50 
AnswerRe: behavior of Value Tuples in .NET 4.7 Pin
Gerry Schmitz21-Jun-17 3:15
mveGerry Schmitz21-Jun-17 3:15 
QuestionRemoving an element from the content of a string value which is HTML code Pin
Farhad Eft19-Jun-17 1:55
Farhad Eft19-Jun-17 1:55 
AnswerRe: Removing an element from the content of a string value which is HTML code Pin
OriginalGriff19-Jun-17 2:12
mveOriginalGriff19-Jun-17 2:12 
GeneralRe: Removing an element from the content of a string value which is HTML code Pin
Farhad Eft19-Jun-17 2:46
Farhad Eft19-Jun-17 2:46 
GeneralRe: Removing an element from the content of a string value which is HTML code Pin
OriginalGriff19-Jun-17 2:55
mveOriginalGriff19-Jun-17 2:55 
QuestionWindows media player issue Pin
Member 1326418716-Jun-17 20:37
Member 1326418716-Jun-17 20:37 
AnswerRe: Windows media player issue Pin
OriginalGriff16-Jun-17 21:34
mveOriginalGriff16-Jun-17 21:34 
QuestionChanging an Image during runtime from resources Pin
Member 1319657416-Jun-17 5:10
Member 1319657416-Jun-17 5:10 
AnswerRe: Changing an Image during runtime from resources Pin
BillWoodruff17-Jun-17 13:12
professionalBillWoodruff17-Jun-17 13:12 
QuestionSystem.IndexOutOfRangeException Pin
joost.versteegen14-Jun-17 21:46
joost.versteegen14-Jun-17 21:46 
AnswerRe: System.IndexOutOfRangeException Pin
OriginalGriff14-Jun-17 22:19
mveOriginalGriff14-Jun-17 22:19 
GeneralRe: System.IndexOutOfRangeException Pin
joost.versteegen14-Jun-17 22:26
joost.versteegen14-Jun-17 22:26 
GeneralRe: System.IndexOutOfRangeException Pin
OriginalGriff14-Jun-17 22:38
mveOriginalGriff14-Jun-17 22:38 
GeneralRe: System.IndexOutOfRangeException Pin
joost.versteegen14-Jun-17 22:41
joost.versteegen14-Jun-17 22:41 
GeneralRe: System.IndexOutOfRangeException Pin
OriginalGriff14-Jun-17 23:01
mveOriginalGriff14-Jun-17 23:01 
GeneralRe: System.IndexOutOfRangeException Pin
joost.versteegen14-Jun-17 23:08
joost.versteegen14-Jun-17 23:08 

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.