Questions tagged as 'c#'

2
answers

Is there a way to implement an interface in a class of a DLL that I can only read?

I'm using a DLL that has several classes. I would like to dynamically implement interfaces for these classes, so that I can perform unit tests by doing mock of them. Is there any way to do this? Example: The DLL has a class Comunic...
asked by 03.11.2017 / 13:29
3
answers

Property set in constructor only returns zero value

I created a Web API in C # that returns me a list of products in JSON. However, the PrecoVenda property is always returned with a value of zero and I noticed that this occurs because in the constructor of the Produto class, Prec...
asked by 28.05.2018 / 01:00
2
answers

Limit decimal places float c #

I would like to show the mediadesp and the mediareceit with 2 decimals after the comma. private void MediaReceitaseDespesas() { /* ----TOTAL / QTDE DE VALORES INFORMADOS----*/ mediadesp = somadesp / despesas.Count;...
asked by 19.04.2018 / 16:38
2
answers

DisplayNameFor and DisplayFor

Studying ASP.NET MVC, I came across the following lines of code: @Html.DisplayNameFor(model => model.Title) @Html.DisplayFor(model => model.Title) I can not understand the difference between using DisplayNameFor and DisplayF...
asked by 08.08.2017 / 19:21
4
answers

Error Deserialize Json in Model C # [duplicate]

Friends, I'm getting error to do the deserialize of the following JSON: { "Comanda": [ { "status": "Produzido (Codigo 3)", "estabelecimento_id": 18, "cliente_nome": "Marcos Manfrin",...
asked by 22.08.2017 / 16:57
2
answers

Validating TextBox

I have the following code snippet that limits a TextBox to receive only numbers and commas: private void txtTempoAcel1_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8 &...
asked by 23.01.2017 / 15:05
2
answers

Receive by parameter a Varied object list

I have the following problem described in the comment: public class Funcionario{ public long Id {get; set;} public string Nome {get; set;} public DateTime DataContrato {get; set;} } public class Carro{ public long Id {get; set...
asked by 26.10.2016 / 21:26
3
answers

How to generate new code from DBO

I have a table with the name Produtos where I inserted 3 products for testing. Now I'm setting up the product registration form and I need to always generate a sequential product code from the last id already registered + 1. The code I...
asked by 14.07.2016 / 15:26
5
answers

How to get index of the current iteration of a foreach?

Normally, in order to get the current iteration index within a foreach , I do this: int i=0; foreach (var elemento in list) { // Qualquer coisa i++; } I believe there are other methods to get the iteration index (even mo...
asked by 06.09.2016 / 03:43
3
answers

Get object content without knowing the attribute name

In JavaScript I have, for example, the object: var meuCarro = { fabricacao: "Ford", modelo: "Mustang", ano: 1969 }; And to access its contents, when I do not know the name of the attribute, I can access this way: var atributo...
asked by 13.04.2018 / 16:08