• Uncategorized

    Currency dispaly tip

    Task: print a price according to a culture information but remember “we don’t need the damn ? (or $) sign”! Well: public static string FormatCurrency(double price) { CultureInfo ci = new CultureInfo("de-DE"); NumberFormatInfo nfi = ci.NumberFormat; nfi.CurrencySymbol = ""; string s = price.ToString("c", nfi).Trim(); return s; } public static double FromCurrency(string price) { CultureInfo ci = new CultureInfo("de-DE"); NumberFormatInfo nfi = ci.NumberFormat; nfi.CurrencySymbol = ""; double d; double.TryParse(price, NumberStyles.Currency, nfi, out d); return d; } An please print the percentage but without the damn % and ALWAYS with 5 decimal digits. public static string FormatInterest(double interest) { CultureInfo ci = new CultureInfo("de-DE"); NumberFormatInfo nfi = ci.NumberFormat; nfi.NumberDecimalDigits = 5; string…

  • Uncategorized

    All the fuss about FizzBuzz

    Recently I’ve read once again about the FizzBuzz. For those not familiar with this term: Fizzbuzz is a taks that could by used while interviewing a software developer for a job. It’s is essentially a trivial task of listing all the numbers from 1 to 100 but replacing multiples of 3 with Fizz, multiples of 5 with Buzz and multiples of both with FizzBuzz. A task that an intelligent person, with some background in software development, suppose to crack in 5 (10 tops) minutes. But of course there are good solution and better solutions. I’m thinking about the solutions provided after Jeff Attwod post on his blog. People are so…

  • Uncategorized

    Redirecting standard input

    Lets say you have to start a program with a parameters from a file. With a command line you will write simply something like that: program.exe < ParamFile.txt Using System.Diagnostics.Process you cannot redirect a content of a file to an external application like that. You have to redirect standard input to you process. You can do it like this: StreamWriter paramFileStreamWriter = someProcess.StandardInput; string[] paramData = File.ReadAllLines(paramFile); for (int i = 0; i < procedData.Length; i++) { paramFileStreamWriter.WriteLine(paramData[i]); } paramFileStreamWriter.Close(); Some more information is to by found on MSDN. Originally published at Saturday, November 11, 2006

  • Uncategorized

    Forms Authentication and ASP.NET Development Server

    If you are using forms authentication while developing with ASP.NET Development Server and you have some static elements to show on the login form (I’m sure you have) you will have a problem with standard configuration. Before the user is authenticated by ASP.NET, he will not see the images and the css will not by loaded. Well its not a big deal because the same website deployed on the IIS will behaves correctly. But if you are perfectionist like me it will by annoying to see something like this: It’s way better to see something like this: Here’s the reason why this happens. By default passes IIS all the static…

  • Uncategorized

    Welcome to IProgrammable.com

    Welcome to my blog. Few years ago when the big blog balloon blow up I surely wasn’t expecting me to blog. But the times are changing. Everybody has a blog so I’ll have mine too 😉 I wont write here about my cat or daughter (have neither). I’ll write about what I do. I’m software developer. I write mostly in .NET (C#) but I have background in Java (J2EE) and PHP. My main point of interest is web development. So think about that. The new ASP.NET web project in version 2.0 is not compiled to one assembly. You have a bunch of small assemblies (when you publish without the possibility…