NPSF3000

The Percent Conversion [TDWTF]

Feb 2nd, 2012
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. //http://thedailywtf.com/Articles/The-Percent-Conversion.aspx
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace TDWTF_Percent_Conversion
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Public ReadOnly Property BatteryPercent()");
  14.             Console.WriteLine("' This code will retrieve the BatteryLifePercent property and convert it to a percent.");
  15.             Console.WriteLine("Get");
  16.             for (float i = 100; i > 0; i--)
  17.             {
  18.                 Console.WriteLine("{0}If SystemInformation.PowerStatus.BatteryLifePercent.ToString = \"{1}\" Then", i != 100 ? "Else" : "", i / 100);
  19.                 Console.WriteLine("Return \"{0}%\"", i);
  20.             }
  21.             Console.WriteLine("Else");
  22.             Console.WriteLine("Return \"NA\"");
  23.             Console.WriteLine("End If");
  24.             Console.WriteLine("End Get");
  25.             Console.WriteLine("End Property");
  26.             Console.ReadLine();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment