using System; using System.Collections.Generic; public class Test { public static void Main() { MainX(new String[] { "50", "Fahrenheit", "To", "Celsius"}); } delegate double TemperatureConvert(double valor); static Dictionary converters = new Dictionary { {"CelsiusToFahrenheit", TemperatureConverter.CelsiusToFahrenheit}, {"CelsiusToKelvin", TemperatureConverter.CelsiusToKelvin}, {"FahrenheitToCelsius", TemperatureConverter.FahrenheitToCelsius}, {"FahrenheitToKelvin", TemperatureConverter.FahrenheitToKelvin}, {"KelvinToFahrenheit", TemperatureConverter.KelvinToFahrenheit}, {"KelvinToCelsius", TemperatureConverter.KelvinToCelsius} }; static void MainX(string[] args) { var temperature = double.Parse(args[0]); var conversor = args[1] + args[2] + args[3]; var convertedTemperature = converters[conversor](temperature); Console.WriteLine(convertedTemperature); } } public static class TemperatureConverter { public static double CelsiusToFahrenheit(double valor) { Console.WriteLine("CelsiusToFahrenheit " + valor); return valor; } public static double CelsiusToKelvin(double valor) { Console.WriteLine("CelsiusToKelvin" + valor); return valor; } public static double FahrenheitToCelsius(double valor) { Console.WriteLine("FahrenheitToCelsius" + valor); return valor; } public static double FahrenheitToKelvin(double valor) { { Console.WriteLine("FahrenheitToKelvin" + valor); return valor; } } public static double KelvinToFahrenheit(double valor) { Console.WriteLine("KelvinToFahrenheit" + valor); return valor; } public static double KelvinToCelsius(double valor) { Console.WriteLine("KelvinToCelsius" + valor); return valor; } }