Questions tagged as 'c#'

2
answers

Merge two distinct lists using LINQ

I have two classes, Cliente and Endereco , where the client has 1 or more addresses, so it is a list of objects: class Cliente { public string Nome { get; set; } public string Cpf { get; set; } public List<Endereco&...
asked by 21.07.2015 / 17:34
2
answers

How to create a class and pass a value of an attribute in the class constructor in C #

Hello, I'm doing an integration with the Tray Comerce API and thought about generating a generic class with the list answer . In all listings, the API implements the following return class: public class Response<T> { [JsonPropert...
asked by 20.06.2018 / 15:34
2
answers

"The process can not access the file because it is being used by another process"

I have a class that retrieves data from bank and saves in a D.Reader, and I write each record in a text file, in this method: public void Escreve_Arquivos_Txt() { string folder = Program.caminhoAplicacao + @"\Serializer"; //Cria...
asked by 24.05.2018 / 17:21
1
answer

Why use readonly to instantiate?

I have read and relayed this question / answer a few times and I understand the difference between const and readonly . I have also read the documentation , but I still can not understand what the gain is I have when using rea...
asked by 17.05.2018 / 18:56
3
answers

Is there any way to dynamically add attribute to instantiated object in C #?

Well, in C # we put attributes as follows: [Required("Este campo é obrigatório")] public string Nome {get; set;} What I would like to know is whether there is a way to dynamically add attributes to instantiated objects. Like the following h...
asked by 26.05.2018 / 17:04
2
answers

Calling a jquery function in tab change

I have a jquery function that mounts an html. It turns out that there is a View with 4 tabs. I would like when selecting a certain tab, the function would be called and of course, loading the dynamic html to mount the page. What event do I do? I...
asked by 13.06.2014 / 16:40
2
answers

How to create a report in Sql Server with information by date

I am creating a system for output management, one of my tables stores the output history information, it has the following columns, IDpedido, DataDoPedido CodProduto, QuantidadeProduto CustoProduto (preço de custo) VendaProduto (preço de venda...
asked by 25.04.2018 / 19:37
1
answer

Round minutes C #

I have a problem that is the following, I need to round the minutes of an hour, for example: if the time is 12:28 I need it to turn 12:30, I need to always round to bigger, does anyone know how to solve this ? Remembering that I'm working with Ti...
asked by 24.04.2018 / 16:07
2
answers

Doubt Console.ReadLine

The user then typed in the console: adicionartempo;(qualquer número que ele digitou) string adicionartempo = Console.ReadLine(); After typing this, how can I get the number he typed and type in Console.WriteLine? This way: Console.Wri...
asked by 11.11.2017 / 01:23
1
answer

SumAsync return zero

I have a query in LINQ where I use SumAsync , however when my entity is empty I have the exception:    The cast to value type 'System.Decimal' failed because the   materialized value is null. Either the result type's generic para...
asked by 08.01.2018 / 14:53