Most voted ".net" questions
The Microsoft . NET is a set of libraries and functions that are part of the Basic Class Library (BCL), such as user interface functions, data access, connectivity, cryptography, web development, mathematical algorithms, and network communication.
Learn more…2,689 questions
Sort by count of
-
22
votes3
answers11209
viewsDifference between Any, Contains and Exists
What’s the difference between Any, Contains and Exists? What is the appropriate context for each of them? (Examples of use) What are the advantages and disadvantages?…
-
21
votes5
answers6769
viewsShould I use GUID or int as the primary key?
I’m about to start a new project in MVC 4 with Entity Framework, searching I found several examples here in Sopt of models that use GUID as ID and some doubts have arisen me: What is the advantage…
-
21
votes1
answer3068
viewsHow Do We Really Understand Streams?
Work for a while with C# and . NET and several times I have seen the use of streams out there for reading files, writing HTML response, uploading files and etc. It turns out that I until today did…
-
21
votes6
answers502
viewsEmpty semicolon doesn’t make a mistake?
I was working on a project and unintentionally bumped into the semicolon that ended up being inserted well after a if. I was intrigued because Visual Studio did not point out as an error, and when…
-
21
votes1
answer622
viewsAt what times is it necessary to force garbage collection in C# for better application performance?
Usually I always have doubts about the use of functions for memory release, in which situations should it be used or should it always be used? And mine really will perform better? If possible…
-
21
votes2
answers3969
viewsWhat is Garbage Collector and how does it work?
What is Garbage Collector, how it works? When should we care about him?
-
20
votes2
answers3325
viewsWhat would be real cases of use of functional programming in the world . NET (F#)?
Recently (Okay, it’s been a few good months) I’ve been interacting with f-language#, which is Microsoft’s response to offer a functional programming language on the . NET platform. However, it is…
-
20
votes2
answers25606
viewsWhat 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 better to use, I ask this question for educational purposes since I see several examples of people using double in C#. But I’ve had problems with double for coin…
-
20
votes5
answers1879
viewsWhat is the difference between an explicit cast and the operator as?
Whenever I convert an object to a specific type, I use a cast explicit, for example: private void textBox1_Leave(object sender, EventArgs e) { TextBox textBoxTemp = (TextBox)sender;…
-
20
votes2
answers1527
viewsWhat are and how do . NET technologies relate to developing web systems?
Many years ago I programmed a little in classic ASP and did not follow the evolution of products. Classic ASP basically consisted of files .asp with code whose language was a variation of Basic,…
-
20
votes1
answer422
viewsIs replacing strings with Regex slower than Replace()?
Let’s say I want to do something like this question: How to convert Camelcase to snake_case in C#? You had some answers, but I want to highlight these two. Answer 1 string stringSnake =…
-
20
votes3
answers2015
viewsWhat is the difference between async, multithreading, parallelism and competition?
What is the difference between async, multithreading, etc..? They depend on the amount of processor cores? If I do a program in Visual Basic and open 33 instances of it, would it be running in…
-
20
votes4
answers9040
viewsHow to return 2 or more values at once in a method?
It is common to see examples of methods returning one value at a time. I’ve seen cases where you need to create a class only to package the data and be able to return more values. Use the generic…
-
20
votes3
answers8582
viewsWhat are Parallel.For and Parallel.Foreach loops?
I saw the use of Parallel.For and Parallel.ForEach in some places, I know they are loops, but I didn’t understand how and when to use them and I have my doubts. What are loop Parallel.For and…
-
19
votes1
answer1277
viewsWhat is "Runtime Environment" really?
Studying a little about ASP.NET 5 I came across something I did not understand very well. To use it you need to install KVM (K Version Manager) and KPM (K Package Manager). KVM is responsible for…
-
19
votes3
answers1592
viewsWhat is System.Linq for?
I asked that question here at SOPT What is the equivalent of PHP’s C array_map#? And I was curious to know what this is about System.Linq. Because when I tried to use the answer code above without…
-
19
votes2
answers5046
viewsWhat is the difference between Isnullorempty and Isnullorwhitespace?
Li here that there is no practical difference between String.Empty and "", and then the doubt came to me. What’s the difference between using String.IsNullOrEmpty(String) and…
-
19
votes4
answers1350
viewsHow to pass string by reference?
I passed a string as a parameter. As far as I know it is passed by reference, so if I change anything in it within the method, when it leaves it the value will continue to change. I took the test…
-
18
votes1
answer1702
viewsWhat’s the right way to call the C#versions?
There seems to be some confusion with the nomenclature of the versions of C# and the technologies that are related to it. Is there a C# 2005? Or a C# 3.5? How do C# versions relate to . Net, Visual…
-
18
votes1
answer2737
viewsWhat’s the difference between "throw" and "throw ex"?
I saw that the C# allows to do... try { //algum código } catch { throw; } also... try { //algum código } catch (Exception ex) { throw ex; } and... try { //algum código } catch (Exception) { throw; }…
-
18
votes2
answers484
viewsIs there an opposite for `contains`?
I have a list: List<int> lista1 = new List<int>(); lista1.Add(1); lista1.Add(2); lista1.Add(3); List<int> lista2 = new List<int>(); lista2.Add(1); lista2.Add(2); To get the…
c# .net entity-framework linq lambda-expressionsasked 9 years, 7 months ago Jedaias Rodrigues 6,718 -
18
votes3
answers1166
viewsWrite Timespan in full
I want to write a static class (can be Extension) to represent the value of a structure TimeSpan in full, in Portuguese. The idea is to always compare the current date (Datetime.Now) with the date…
-
18
votes2
answers10850
viewsWhat is the main difference between int. Parse() and Convert.Toint32()?
In C#, there are two ways (among others) to convert other types to int: Convert.ToInt32(valor) and Int32.Parse(valor). What is the main difference between these two forms of conversion?…
-
18
votes1
answer314
viewsIs it correct to use a block using inside another using block?
It is correct to use a block using inside another block using as in the example below? or just put the first using? public DataTable Listar(string stringMySql, CommandType commandType,…
-
18
votes3
answers8119
viewsWhat are the best practices in field validation?
I created an example to illustrate my doubt regarding field validation, the example is composed of two classes Pessoa and ModelPessoa. The class Pessoa has the following attributes: Nome, Idade,…
-
18
votes2
answers847
viewsHow does running an . NET application work?
There are several terms I always hear/read when I see talk about running. NET applications, such as MSIL, CIL, IL, JIT, Jiter, Roslyn, CLR, among others I must have forgotten. I would like a brief…
-
18
votes1
answer520
viewsWhat am I supposed to understand when they say ". NET"?
I’m starting to learn C#. I already understand what the Runtime and what is CLI, but turns and moves quote . NET as if it was something I should already know, but I do not understand. Just say . NET…
-
17
votes5
answers2401
viewsHow do I merge two results of a query?
I am developing an application in C# and I would like to know how to put together two results of two darlings SQL in one. I have the following code: public List<MalaDireta> ObterMalaDireta() {…
-
17
votes2
answers9060
viewsBest practice for logging the system
What is the best practice for registering a log system? public void inserirLog(string Acao) { StringBuilder csql = new StringBuilder(); csql.Append("insert into Log (Acao,data) values(");…
-
17
votes1
answer11086
viewsHow to check the execution time of a method?
Example: I have the Metodo1 and the Metodo2 both have different processing and actions. I want to check how long each takes to run. How do I do that?
-
17
votes1
answer628
viewsWhat is C#metadata?
What is C#/. NET metadata? What are they for, and how can I use them? I was watching a template of Visual Studio, and browsing the files, I came across them.
-
17
votes2
answers1493
viewsWhat can I do in . NET Framework and . NET Core not? And vice versa
I grew my eye on . NET Core (ASP.NET Core), I started with C#, but I left it by going sideways "open-source", now with this opportunity I decided to "return". I intend to use . NET Core (ASP.NET…
-
17
votes4
answers936
viewsWhy is the use of Dynamic something to be avoided?
My company works with development, it is a company practice that all codes made are reviewed by another person before they are approved in pull request. Usually my codes have only a few details to…
-
16
votes5
answers14262
viewsHow to sort list with complex object by one of its properties?
I have a list of objects and I want to sort the list by one of the properties (Desc type string), how do I do this? public class Foo { public string Desc { get; set; } // Várias outras propriedades…
-
16
votes3
answers6549
viewsWhat are providers? What is the difference between OLE DB and ODBC?
I need to read files dbf. I found a tutorial to read the same where the author uses these two providers. I only saw differences in the connection string. What are these providers? What is the…
-
16
votes3
answers4284
viewsWhat is the probability of generating a Repeated Guid?
What is the probability of generating a Repeated Guid with Guid.NewGuid()? I am uploading numerous images from my system. The same will be a Multitenancy, and will share the same Deploy, from the…
-
16
votes3
answers7424
viewsWhat are the main differences between VB.NET and C#?
In addition to syntax, what are the main differences between these two languages? Is there any difference in performance between them? Or is there any case where it is extremely advisable to use one…
-
16
votes2
answers1619
viewsMulti-core Cpus - Why doesn’t my application use all the processor cores?
I have a doubt I can’t find a convincing answer. There is an application developed in Delphi 7, and in an extremely complex routine (it takes about 2 hours) we notice that it is only used for the…
-
16
votes1
answer10829
viewsHow to make the app wait for a while?
It is common to have situations that we need to delay the execution of the code for a period, whether to show or delete a message or something visual shortly after, or to try something again, to…
-
16
votes2
answers1211
viewsWhat is the difference between using (int)variable or Convert.Toint32(variable)?
What is the difference between them? At what times is it more appropriate to use one or the other? Examples: string palavra = "10"; var numero = Convert.ToInt32(palavra); // ou (int)palavra ? string…
-
16
votes3
answers4507
viewsWhat is the point of "interrogation" in the type statement in C#?
I saw this code written in C# on the Internet: namespace Test { [MicroEntitySetup(TableName = "Users")] public class User : MicroEntity<User> { [Key] public int id { get; set; } public string…
-
16
votes3
answers3624
viewsWhen to use asynchronous or synchronous method?
When to use asynchronous or synchronous methods in controllers (index, search, delete, create) of ASP.NET MVC applications? Can I lose performance? In which situations should I use one or the other,…
c# asp.net-mvc .net entity-framework asynchronousasked 7 years, 10 months ago George Wurthmann 4,415 -
15
votes1
answer167
viewsWhat is the character function ? in the variable type in C#?
I see many third-party codes and I often see the use of the question mark on the type of the variable. Example: public bool? Status Could someone explain to me the difference between not having this…
-
15
votes2
answers5787
viewsCut string when it reaches space
Example: I have a string "João da Maquipe", as I do to cut in space, leaving as a result: "João" or "João". whatever. In PHP I know, but in C# I have no idea.
-
15
votes2
answers1287
viewsWhat is the purpose of a static constructor?
I’ve always used builders as follows: public MinhaClasse() { //Algo ... } However I found that in C# it is possible to create a static constructor as follows: public class MinhaClasse { public…
-
15
votes2
answers5495
viewsWhat are Async methods?
I noticed that most methods in C# have an equal method but with a name async. What are these methods and how they work?
-
15
votes2
answers1617
viewsWhat is LINQ technology?
Today reading some contest questions, appeared one in which it was LINQ technology. Without delving too much into the research I noticed a number of quotes as: LINQ to SQL LINQ to XML (C#) LINQ to…
-
15
votes1
answer193
viewsWhat is the minimum size of an object in memory?
I received an answer in my question that talks about a overhead that the object has. Every object has this overhead? An object without data also has this overhead? Exists object of size 0?…
-
15
votes8
answers2223
viewsError: not all code paths Return a value
I would like to understand why my code is causing the error not all code paths Return a value using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using…
-
15
votes3
answers361
viewsIs it correct to call a method, and pass your null parameters?
For example, I have the event of click of a button calling the method below: //Evento this.serviçoToolStripMenuItem1.Click += new System.EventHandler(this.Nivel_Serv_Click); //Metodo private void…