Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement