Questions tagged as 'c#'

2
answers

How does GroupBy work in LINQ?

I'm having trouble understanding the GroupBy operator in LINQ.     
asked by 26.08.2015 / 21:23
2
answers

When is it advisable for a class to implement IDisposable?

I use the IOC standard in my project which facilitates the procedure call of type Resolver.Resolve<IPedido>().GerarPedido() , but I did not want to leave it "loose" in this way, I would like to implement the method IDisposable...
asked by 15.11.2015 / 18:27
2
answers

Method to execute when destroying instance of a class

Is there any way to automatically execute a method by destroying an instance of a class. I have a generic SQL class, where in the constructor I call a method that opens the connection. Only I want to close this connection automatically too, with...
asked by 20.11.2014 / 13:30
1
answer

Accessing MySQL with C #

I am creating a simple Form that has 3 TextBoxes and 3 buttons and I want to save the information entered in Textboxes in a table. I have already created querys all within a class acessoBD , but I can not acc...
asked by 24.09.2015 / 03:00
2
answers

Where to put Data Annotation? View Model or Model?

Using Entity Framework Code First, with view model and model . To create a column with varchar(2) , I need to put MaxLength(2) in model and view model ?     
asked by 28.08.2015 / 21:32
3
answers

How to send 2 Controller objects to the View in C # ASP.Net MVC?

I made a query in the database in 2 tables and saved in 2 objects in the controller , but I can only send 1 object to view . // Controller // Pego os dados do BD e salvo no objeto var objPessoa = new PessoaAplic(); var dadosPessoa = objPesso...
asked by 06.10.2015 / 21:22
2
answers

Good practices in declaration of variables in a for

Lately I've been using Resharper and I've enjoyed the experience of using it, but something has intrigued me. At times it suggests that certain variables be declared within some scopes, as in the example below: var a = 0; for(var i = 0; i&...
asked by 08.12.2016 / 12:34
2
answers

Variable of foreach loop

When we use a foreach loop, does the local variable we create to receive the content of the list in question pass by value or reference? Ex: foreach (var item in listItems) { //TODO } Does item receive content by value o...
asked by 24.08.2017 / 16:31
2
answers

What is @ in a view and controller?

I program in PHP and am starting to learn how to program in C # ASP.Net MVC, however I have some questions: What is the @ (arroba) serving in both the controller and the view ? What is the purpose of these { get; set; } calls th...
asked by 05.10.2015 / 18:06
2
answers

How to get the integer value of one of the constants of an enum?

I have an enum (enumeration) calling Notas and I need to get the integer corresponding to one of its constants. public enum Nota { Otimo = 5, MuitoBom = 4, Bom = 3, Regular = 2, Ruim = 1, Insuficiente = 0 } I...
asked by 15.12.2013 / 03:22