Search⌘ K
AI Features

Solution: Fitness Tracker Log

Understand how to implement dynamic binding in C# by working through a fitness tracker example. Learn to use dynamic return types for method flexibility and how to handle different data formats dynamically, enhancing your grasp of the Dynamic Language Runtime and ExpandoObject.

We'll cover the following...
C# 14.0
using FitnessApp;
var tracker = new FitnessTracker { DistanceRunInKm = 10 };
dynamic result = tracker.GetDistance("metric");
Console.WriteLine($"Metric result type: {result.GetType()}, value: {result}");
result = tracker.GetDistance("imperial");
Console.WriteLine($"Imperial result type: {result.GetType()}, value: {result}");
...