Skip to content

Instantly share code, notes, and snippets.

@bbqchickenrobot
Last active December 25, 2018 21:37
Show Gist options
  • Select an option

  • Save bbqchickenrobot/55f31ff06bf89f29c990c34e8d58cd34 to your computer and use it in GitHub Desktop.

Select an option

Save bbqchickenrobot/55f31ff06bf89f29c990c34e8d58cd34 to your computer and use it in GitHub Desktop.
// There is no 'Main' class here as I used Xamarin Workbooks
// https://docs.microsoft.com/en-us/xamarin/tools/workbooks/install?tabs=windows
#r "Newtonsoft.Json"
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
void displayTuple((int count, string value) val){
Console.WriteLine($"Count: {val.count} - Value: {val.value}");
}
var stringContent = "The answer to everything";
var mixedTuple = (42, stringContent);
Func<(int count, string value)> func = () => {
return mixedTuple;
};
var val = func();
displayTuple(val);
var json = JsonConvert.SerializeObject(val);
var test2 = JsonConvert.DeserializeObject<(int count, string value)>(json);
displayTuple(((int count, string value))test2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment