Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 15, 2016 20:31
Show Gist options
  • Save Fhernd/0dd3164d4b5416eedb5d98a3f14f1bcd to your computer and use it in GitHub Desktop.
Save Fhernd/0dd3164d4b5416eedb5d98a3f14f1bcd to your computer and use it in GitHub Desktop.
Prueba de Temperatura. [OrtizOL]
using System;
using System.Globalization;
namespace Cap06_FormatoParseo
{
public class TemperaturaWorker
{
public void Ejecutar()
{
// Formato compuesto:
Temperatura temp = new Temperatura(0);
Console.WriteLine("{0:C} (Celsius) = {0:K} (Kelvin) = {0:F} (Fahrenheit)\n", temp);
// Formato compuesto con proveedor de formato:
temp = new Temperatura(-40);
Console.WriteLine(
String.Format(CultureInfo.CurrentCulture,
"{0:C} (Celsius) = {0:K} (Kelvin) = {0:F} (Fahrenheit)",
temp));
Console.WriteLine(String.Format(new CultureInfo("fr-FR"),
"{0:C} (Celsius) = {0:K} (Kelvin) = {0:F} (Fahrenheit)\n",
temp));
// Invocación a `ToString` con cadena de formato:
temp = new Temperatura(32);
Console.WriteLine("{0} (Celsius) = {1} (Kelvin) = {2} (Fahrenheit)\n",
temp.ToString("C"),
temp.ToString("K"),
temp.ToString("F"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment