Question

I need a help (c#) for the following problem:

  • I have this value as int : 11110006;
  • I want to show this value with this specific mask: 0:0.0.0.00.00-0
  • the result must be 1.1.1.10.00-6

In my view, I already tried:

<td style="text-align:left"><%= String.Format("{0:0.0.0.00.00-0}", cosif.IDCONTACOSIF) %></td>

and

<td style="text-align:left"><%= String.Format("{#:#.#.#.##.##-#}", cosif.IDCONTACOSIF) %></td>

Or even

<td style="text-align:left"><%= cosif.IDCONTACOSIF.ToString("My Mask ###") %></td>

Nothing is working... sometimes, it shows like a currency number, but I don't want to show it like a currency, because it isn't a currency value.

Any idea?

Best regards..

Was it helpful?

Solution

To use a format string in the form of 0:0.0.0.00.00-0 try using single quotes or double quotes to encase the periods in the format string. As it is being interpreted as a decimal separator, as in 0.45678 ("0.00", en-US) -> 0.46

So for example try: ("#':'#'.'#'.'#'.'##'.'##'-'#")

this text shows the place holders in the format string you should use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top