Sunday 24 March 2013

Interview Series - Currency Display


In many Financial and Accounting Applications, it’s very important to ensure that the Currency specifications are perfect.

Here in this setup of an Interview, we’ll see how to cater to the specific needs of Currency display depending upon the location where the systems are present.


This Interview series shows the power of string.Format, one of the most powerful features performable on strings. String.Format caters to a wide variety of applications (Refer to MSDN!). We can specify predefined Expressions or write our own custom Regex to get the formats we prefer.

The Interview series also showcases the usefulness of Nullable type of variables. It also highlights about the Null-Coalescing operator. There’s also some light shed on double variables holding “NaN” values in them and how to take care of such values.

Please check out the 4 video links where I go through this simulated Interview in more detail.











The code typed-in during the interview series is as follows for your reference:-

            //Currency Unit for a value

            //string answer = "Rs. " + value;
            //MessageBox.Show(answer);

            //string value = "12.5";
            //string value = null;
            //string value = "-12.5";
            string value = "NaN";
            //double number = Convert.ToDouble(value);
            //string answer = string.Concat("Rs. ", number);
            //MessageBox.Show(answer);

            //string answer = string.Format("{0:C}", number);
            //MessageBox.Show(answer);

            // number --> nothing display nothing
            //number --> 12.5 --> Display $ 12.5
            //double number;
            //Nullable<double> number;
            double? number;

 string answer = string.Format("{0:C}", (number = Convert.ToDouble(value)) == 0.0 ? null: number > 0.0 ? number : null);

            MessageBox.Show(answer);

            double xx = 12.5;

            if (!double.IsNaN(xx))
            {

            }

Thank you for reading this post and watching the videos. Please Subscribe, Comment and Rate the channel if you liked the video.

Goto C# Experiments to access more of such content! Thanks again!

No comments:

Post a Comment