C # - Pass only numbers in a currency formatted field

-2

I have an application that shows me in a textbox the value of a course enrollment:

string mensalidade = string.Format("{0:C}", Convert.ToDouble(leitura["Mensalidade"]));
cursoSelecionado.Mensalidade = mensalidade;
tb_Mensalidade.Text = Convert.ToString(cursoSelecionado.Mensalidade);

As we can see, the field displays the value of this course formatted for the currency style. However, I need to pass only the value of this course, as decimal, to my database (SQL Server).

inserirMatricula.Parameters.Add("@Mensalidade", SqlDbType.Decimal).Value = ???;

How can I do this?

    
asked by anonymous 13.03.2018 / 23:16

1 answer

1

I use this code. I assume the reading value ["Monthly"] is as shown below.

    private void Parse()
    {
        decimal x = 0;
        string mensalidade = string.Format("{0:C}", Convert.ToDouble("23,3"));

        x = decimal.Parse(mensalidade, NumberStyles.AllowCurrencySymbol | NumberStyles.Number);

    }
    
13.03.2018 / 23:40