Questions tagged as 'c#'

1
answer

Difference between Task and Thread

I need to create a C # executable and I have the doubts: Do with thread or do with task ? In practice is there any difference between using Task and the "traditional" multi-thread ?? Is it true that a task...
asked by 13.04.2016 / 18:57
2
answers

Compile string as code

How can I compile a string inside C #? Example: Console.WriteLine(\"Hello World\"); . As if it were a eval of JavaScript? I had a project to load a code into a text file or something else.     
asked by 10.05.2014 / 02:10
3
answers

SQL in the code or in the database?

I have a big question as to where to put my query SQL, whether in the code or the bank . I currently have a procedure that is set up according to the parameters I have, ie filtros . Procedure @escopoVerificacao varchar(MAX) =...
asked by 24.02.2015 / 21:20
2
answers

What is the difference, in practice, between "" and String.Empty?

In .NET you can see the multiple ways to initialize a string with an empty value, commonly known as "double quote". Is there a proper way to do this? And what would be the practical difference between using: var nome = String.Empty;...
asked by 05.09.2016 / 15:33
2
answers

What is AntiForgeryToken?

What is AntiForgeryToken and what does it serve in an ASP.Net MVC application?     
asked by 09.09.2015 / 20:20
2
answers

What is the difference between "lambda" and LINQ? How to differentiate them in a sentence?

I often see terms like LINQ query and lambda expressions . Then the question came up, What I'm doing is a LINQ query, a lambda expression, or both? Ex1: var query = Produtos.Where(p => p.Descr.StartsWith("A")).Take(10); Ex2: var...
asked by 09.08.2015 / 04:07
1
answer

How to make a test fail if it takes too long?

I'm using MSTest which is the default unit testing platform in visual studio and I have this test here: [TestMethod] [ExpectedException(typeof(InvalidOperationException))] public void Board_nao_destroi_unidades_flutuantes() {...
asked by 12.04.2014 / 15:34
7
answers

Put the constructor of the class as 'private'?

When I put a constructor of a class in C # as private , I get the following error: I would like to know the technical explanation for the reason for this error and if there is any use case of constructor (or one of the constructors)...
asked by 26.02.2015 / 20:36
3
answers

Format double with thousands and decimal

I have the following value: 43239.110000000001 I used this command: txtSomatorio.Text = String.Format( "{0:#.#,##}", somatorio); I achieved this: 43239,11 How do I display it like this? 43.239,11     
asked by 23.12.2014 / 18:45
2
answers

What kind of data (double, float or decimal) should I use to represent currency in .NET with C #?

Although I am aware of what would be best to use, I ask this question for teaching purposes since I see several examples of people using double in C #. But I've had problems with double for coin calculations and read in several pla...
asked by 01.04.2014 / 22:30