Skip to content
Permalink
fe6569f37b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (28 sloc) 893 Bytes
using System;
using System.Globalization;
namespace MauiWeatherForecast
{
public class FahrenheitConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return "0"; // or however you wish to handle null values
}
if (value is double fahrenheit)
{
double celsius = (fahrenheit - 32) * 5 / 9;
return Math.Round(celsius).ToString();
}
else
{
throw new ArgumentException("Expected a double value.", nameof(value));
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}