Questions tagged as 'c#'

1
answer

Var within FOR when it starts at 0 (zero) should Count be Count-1?

I picked up a system in the company where I work for another colleague. I note that all FOR's are like this: for(int i = 0; i < lista.count; i++) { //meu código } I learned that when a variable within FOR starts with zero, my COUNT...
asked by 12.03.2015 / 20:03
1
answer

Compile error: The name 'x' does not exist in the current context [closed]

I'm trying to do this exercise in C #, but every time I try to compile it points out the error:    The name i does not exist in the current context Does anyone know how to solve this? int N, a, b; N = int.Parse(Console.ReadLine()); a =...
asked by 03.07.2018 / 15:03
1
answer

Visual studio code

Good afternoon, I'm creating a web project with visual studio core, the problem is that the command I'm using "dotnet new MVC -o NomePasta" already creates a structure. I'm starting to learn how to develop for web with C # in visual studio code,...
asked by 04.06.2018 / 17:50
1
answer

How to print the name of the method, file and line that was called?

Example: filename: teste.cs Part of the code: ... public void MeuMetodo() { // suponha que essa linha seja a 100 Console.WriteLine("Arquivo: " + arquivo + "Metodo: " + metodo +" linha: " + linha); //Resultado seria:...
asked by 05.01.2018 / 12:14
2
answers

How to use the SUM aggregation function in a NHIBERNATE query?

My query consists of knowing NumCarroId , TotalGasto and VlrUnit , in Sql I could do this but when I play in HQL it returns the following error: Applying GROUP BY to SUM to make a ToList, to show...
asked by 17.01.2018 / 17:25
2
answers

How to have access to the Label again in Visual Studio

I put a Label on the form, edited its name to be empty, renamed and so on, and I can no longer select it in the form for manipulation. It works inside the application bringing the ID of the register, I need to manipulate because it is misalig...
asked by 08.02.2018 / 13:16
1
answer

Save all types of variables in a vector / array?

How can I store values and variables of all types within a vector? Ex: vetor1.Add("valor em string"); vetor1.Add(100); vetor1.Add(100.10); vetor1.Add(-100); I have no idea how I can do this.     
asked by 04.02.2018 / 13:46
2
answers

SelectListItem with custom attributes

I created a DropDownList using the method below: private void PopulateDropDown() { //Chamo o método que obtém a lista de clientes da API List<Models.Cliente> clientes = new Business.Cliente().Get(); //Rotorno a lista de cli...
asked by 05.02.2018 / 21:49
1
answer

Why can not I capture exceptions triggered by async void?

Why can not I catch exceptions triggered by asynchronous methods that do not return Task ? public async void calcularPrecos() { var tabelaPreco = await getTabelaPreco(); /* Blá, blá, blá... */ } public void iniciarCalculos() {...
asked by 25.08.2016 / 04:12
2
answers

If I return something inside a using, will the resources be released?

I know that using is used to release (give dispose ) resources. My question is in the following case: public void FuncNaoFazNada() { using(var acd = new AlgumaClasseIDisposable()) { return; } } In this case,...
asked by 17.08.2016 / 16:02