Click here to Skip to main content
15,886,513 members
Home / Discussions / C#
   

C#

 
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 
OK, we're obviously talking about different things. Laugh | :laugh:

At run-time - when the code is running - your C# code is nowhere in sight. All that exists is the MSIL code, which is the result of various transformations applied by the C# compiler.

The fact that you can write and compile code which uses the named field doesn't mean that the named field is available when the code is running. It just means that the compiler understands it, and knows how to transform it into something that will work at runtime.

If you want to try accessing it when the code is running, try using reflection, or dynamic. You'll see that the named field is not available.
C#
Type t = VTProp.GetType();
Console.WriteLine(t.GetField("S2"));
// "null"


foreach (FieldInfo field in VTProp.GetType().GetFields())
{
    Console.WriteLine(field.Name);
}
// Item1
// Item2
// Item3


dynamic vtp = VTProp;
Console.WriteLine("S2: {0}", vtp.S2);
// RuntimeBinderException: 'System.ValueTuple<string,int,string>' does not contain a definition for 'S2'




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


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 
QuestionDateTimePicker Override right click events Pin
manju 319-Feb-18 23:36
manju 319-Feb-18 23:36 
AnswerRe: DateTimePicker Override right click events Pin
Ralf Meier20-Feb-18 0:34
mveRalf Meier20-Feb-18 0:34 
QuestionSQL Connection and insertion of data in C# form application Pin
Member 1368376518-Feb-18 1:09
Member 1368376518-Feb-18 1:09 
AnswerRe: SQL Connection and insertion of data in C# form application Pin
Richard MacCutchan18-Feb-18 1:39
mveRichard MacCutchan18-Feb-18 1:39 
AnswerRe: SQL Connection and insertion of data in C# form application Pin
Eddy Vluggen18-Feb-18 3:02
professionalEddy Vluggen18-Feb-18 3:02 
SuggestionRe: SQL Connection and insertion of data in C# form application Pin
Richard Deeming19-Feb-18 8:18
mveRichard Deeming19-Feb-18 8:18 
QuestionTesting methodologies Pin
Hila Berger18-Feb-18 0:54
Hila Berger18-Feb-18 0:54 
AnswerRe: Testing methodologies Pin
Richard MacCutchan18-Feb-18 1:35
mveRichard MacCutchan18-Feb-18 1:35 
AnswerRe: Testing methodologies Pin
Eddy Vluggen18-Feb-18 2:41
professionalEddy Vluggen18-Feb-18 2:41 

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.