After a lot of research, I found the article (according to the link below) that specifies and exemplifies well my need. What I had to do was add the Annotation in the corresponding property value, in my model
:
[DisplayFormat(DataFormatString = "{0:0,0.000000}")]`
public decimal valor { get; set; }
Using the mask I need, I was able to print on the screen the correct value of: 48.205864
The original link to the article: https://goo.gl/PpOZVo
In order not to run the risk of the link being deactivated some day, follow below the explanations, which I give credit to the author of the link informed.
Setting the maximum permitted of decimals
To format a number with a maximum of two decimal places, use the string format {0:0. ##} as shown in the following example:
string.Format("{0:0.##}", 123.583); // "123.58"
string.Format("{0:0.##}", 123.586); // "123.59"
string.Format("{0:0.##}", 123.58); // "123.58"
string.Format("{0:0.##}", 123.5); // "123.5"
string.Format("{0:0.##}", 123.0); // "123"
Defining a fixed size of decimals
This is similar to the example above, but instead of hashes (? #') in the formatting string, let’s use zeros (, 0') as follows:
string.Format("{0:0.00}", 123.583); // "123.58"
string.Format("{0:0.00}", 123.586); // "123.59"
string.Format("{0:0.00}", 123.58); // "123.58"
string.Format("{0:0.00}", 123.5); // "123.50"
string.Format("{0:0.00}", 123.0); // "123.00"
The separator of a thousand
To format decimal using the mile separator, use the format string {0:0,0} as shown in the following example:
string.Format("{0:0,0.00}", 1234256.583); // "1,234,256.58"
string.Format("{0:0,0}", 1234256.583); // "1,234,257"
Defining a fixed number of digits before the decimals
To set a minimum number of three digits before the decimals, use the format string {0:000.#}.
string.Format("{0:00.000}", 1.2345); // "01.235"
string.Format("{0:000.000}", 12.345); // "012.345"
string.Format("{0:0000.000}", 123.456); // "0123.456"
Alignment
To specify the alignment to the formatting method, write its format as follows. Note that a comma was used to specify the number of characters used for the alignment.
{0,[no. of characters]} and want to fill with zeros {0,[no. of characters]:00.00}
string.Format("{0,7:##.00}", 2.356); // " 2.36"
string.Format("{0,-7:##.00}", 2.356); // "2.36 "
string.Format("{0,7:00.00}", 2.356); // " 02.36"
string.Format("{0,-7:00.00}", 2.356); // "02.36 "
Positive, negative and zero numbers
You can include different formats for positive, negative, and zero numbers using the dot and comma (?;').
Format string:
//{0:[positive];[negative];[zero]}
string.Format("{0:000.000;(000.000);zero}", 23.43); // "023.430"
string.Format("{0:000.000;(000.000);zero}", -23.43); // "(023.430)"
string.Format("{0:000.000;(000.000);zero}", 0.0); // "zero"
Some predefined formats
string.Format("{0:C}", 1532.236); // "£1,532.24"
string.Format("{0:C}", -1532.236); // "-£1,532.24"
string.Format("{0:E}", 1532.236); // "1.532236E+003"
string.Format("{0:E}", -1532.236); // "-1.532236E+003"
string.Format("{0:F}", 1532.24); // "1532.24"
string.Format("{0:F}", -1532.24); // "-1532.24"
string.Format("{0:G}", 1532.236); // "1532.236"
string.Format("{0:G}", -1532.236); // "-1532.236"
string.Format("{0:N}", 1532.236); // "1,532.24"
string.Format("{0:N}", -1532.236); // "-1,532.24"
string.Format("{0:P}", 0.1532); // "15.32 %"
string.Format("{0:P}", -0.1532); // "-15.32 %"
string.Format("{0:R}", 1532.236); // "1532.236"
string.Format("{0:R}", -1532.236); // "-1532.236"
How is configured your decimal in the database, example
decimal(18,2)
?– novic
@Virgilionovic for these data, the database is configured as decimal(15,6)
– Erico Souza