Questions tagged as 'c#'

1
answer

Object reference not set to an instance of an object. in the declaration of an object

An error is occurring in my code only when I post, when I'm debugging it works normally. the error is as follows: " Object reference not set to an instance of an object. " my code: MkfFile file = new MkfFile(); public class MkfFile { priv...
asked by 03.12.2014 / 17:25
1
answer

SQL command in C #

Well, I'm doing a crud using mvc and the entity framework, but I do not know how to pass parameters ... here's my code public void Cadastrar(TimeModel timeObj) { strQuery = "INSERT INTO TimeFut (nome, estado) VALUES (aqui vai os parâmet...
asked by 17.12.2018 / 17:50
2
answers

Facilities for client, WCF or Web API? [closed]

I need to create a Web service to insert data on a database that needs validation to ensure data integrity. I have as a requirement, to facilitate the use of my "clients". So, should I opt for WCF (SOAP) or Web API (Rest)?     
asked by 11.06.2014 / 19:17
2
answers

Error populating combobox - An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll

This is a cod. to populate a combobox with a list that will populate through the insert event that will retrieve a value from a textbox, and will cause the selected name in combobox1 not to appear in combobox 2 and so on respectively. I'm hav...
asked by 21.05.2014 / 01:15
1
answer

Date is coming in wrong format

In a jquery function, I get a date in my View. It turns out the date is coming like this: /Date(1402369200000)/ I know I need to cast or something, but I do not know how. Can someone give me a help? My controller: [HttpPost] publi...
asked by 16.06.2014 / 16:29
3
answers

C # Display time in textbox control

I need to show only the local time in a TextBox control. In the following format: hh:mm:ss How could I do this in C #?     
asked by 20.02.2016 / 15:53
1
answer

Converting division expression in C ++ to C #

I have the following condition in C ++ and would like to move to C #. The problem I'm having is with the div function that displays the error:    The name 'div' does not exist in the current context if (quant > 0) { return d...
asked by 01.10.2014 / 18:37
1
answer

Calculate percentage

Largura * Complemento = Subtotal + Porcentagem = Total subtotal.Text = (Convert.ToDouble(largura.Text) * Convert.ToDouble(complemento.Text)).ToString(); total.Text = (Convert.ToDouble(subtotal.Text) % Convert.ToDouble(PercaTextBox3.Text)).ToStri...
asked by 05.08.2018 / 18:09
1
answer

Decimal field displays a .0 on the screen

I have a CPF field that is decimal (11). Well, when I show on the grid the CPF it looks like this: 12345678911.0, how can I remove the .0? My ViewModel public class FuncionarioViewModel { [Key] public int id { get; set;...
asked by 13.08.2018 / 20:30
3
answers

Find index of a value in an array

I want to look up the index of an array by a value: List<string> list = new List<string>() { "Leão", "Guepardo", "Elefante" }; String[] array = new String[3] { "Leão", "Guepardo", "Elefante" }; For example, I want to look up the...
asked by 09.08.2018 / 17:14