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
-
12
votes3
answers5129
viewsWhat is the difference between using single and double quotes in C#?
In PHP, when we use single quotes or double quotes, both forms have the functionality to declare a string. There is only one small difference. I am now starting a study with C#. When I went to try…
-
12
votes2
answers1960
viewsEmpty delegate ( delegate { } )
What returns the instruction delegate { }? Would be an empty delegate? In which situations would it be necessary to create an empty delegate?
-
12
votes1
answer751
viewsWhat is the method group?
Coding in C# I ended up making a mistake, perhaps by familiarity with other languages that I usually work, and forgot the parentheses. string.Concat(numero.ToString, "A") I got the following…
-
12
votes2
answers1470
viewsWhat are the pointers?
I’ve come across this in several languages, mainly C and C++, but I’ve never understood what it is, how it’s used, and why it exists. I found out unintentionally that it also exists in C# and it’s a…
-
12
votes1
answer166
viewsWhat would a Nuget be?
I noticed that in various programs and in various locations they are used Nuget, I myself had to use one, but used without knowing the definition of it, I can say that it would be an extension?…
-
12
votes5
answers5490
viewsCount the number of months between one date and another
I would like your help to basically count the amount of months between a date and another. I’ll give you an example but what I want is basically just an accountant. Ex: quantity of months between…
-
12
votes2
answers348
viewsShould or should not Httpclient be used within a using block?
Reading this reply, a question relating to the use of using, I was curious about the following statement: In fact everyone uses HttpClient wrong, I even used and did not know everything, because I…
-
11
votes5
answers2480
viewsCheck if day exists in month
I need to verify/validate if a (numerical) day exists in a given month. For example, I have the day 31, and as it does not exist in the month of February the condition will fail. I think a simple if…
-
11
votes6
answers11946
viewsConverting a string to int?
How best to convert a variable string for another variable of the type int?, namely, a nullable of int? Performance is very important in this case because I will be converting several values within…
-
11
votes2
answers677
viewsWhat is the difference between typeof(T) vs. Object.Gettype()
What’s the difference? Is there any difference between performance?
-
11
votes3
answers1211
viewsConcepts of Mesomorphic Allocation and Liberation in C#
I’m making a web application that has a finite recursive loop. But during the process the memory consumption is constantly growing and at the end Visual Studio has more than 2 Gigas of memory use. I…
-
11
votes4
answers2950
viewsDraw where the name cannot be drawn more than once
I need to make a simple drawing software, but I don’t know how to take the names that were entered in the list box and draw one among them. The same name cannot be drawn more than once. How to do…
-
11
votes2
answers197
viewsNomenclature or language in lambda
We have that expression: var teste = meucotexto.minhatable.Where(x => x.meu_campo.....) How I read that part x => x.meu_campo Leio x is for x.meu_campo or x of x.meu_campo or something else?…
-
11
votes1
answer1726
viewsDifference between Stathread and Mtathread
What is the difference between Stathread and Mtathread and when I should use one or the other? Why and how do they only concern the COM?
-
11
votes1
answer1160
viewsWhat’s the difference between Vent and Delegate?
I see how it works delegate and event, but I saw no use of event. For example: public delegate void ChangedEventHandler(object sender, BaseEventArgs e); public ChangedEventHandler Changed; The code…
-
11
votes2
answers14331
viewsHow does Groupby work on LINQ?
I’m having trouble understanding the operator Groupby on LINQ.
-
11
votes5
answers1656
viewsCreate objects within a list without for/foreach C#
private List<Compra> CriarCompras(int numComprasParaGerar) { List<Compra> lstCompras = new List<Compra>(); for (int i = 0; i < numComprasParaGerar; i++) lstCompras.Add(new…
-
11
votes2
answers604
viewsRead all the contents of a text file
I need to read all the contents of a text file and put it into a string. Usually, I do so: using(var reader = new StreamReader("arquivo.txt")) { var strBuilder = new StringBuilder(); while…
-
11
votes4
answers25519
viewsThe input character string was not in an incorrect format. Operators
Hello, I’m beginner in programming and I’m trying to show the user how much RAM is being consumed at the moment, I’m using the following code that is not pointing nor an error when compiling only…
-
11
votes2
answers121
viewsIs there an alternative to Removeat()?
I am using Entity Framework in an ASP.NET MVC project where I have a simple list of strings and need to remove only the first item. I used the following command: minhaLista.RemoveAt(0); Well, but…
-
11
votes1
answer385
viewsIs the C# language recommended to be distributed online with a database?
It is very easy to get the entire code of a C# program using . NET Reflector. Would it be possible for me to put the same security in a C# program a program made in C++? I found that answer no Stack…
-
11
votes4
answers160
viewsHow can I make a string code work with > or <?
Apparently I’m having problems with strings: public partial class Form1 : Form { private int _adicionar; private int _retirar; public Form1() { InitializeComponent(); } private void…
-
11
votes3
answers1063
viewsWhat is the difference between System.Web.Http and System.Web.Mvc?
I have an MVC project and in it I will have normal controls and controls providing services via webservices (Controller and ApiController). And I don’t know which one to use because I don’t know…
-
11
votes1
answer578
viewsWhy does iteration of a list with an anonymous object work with an array but not with List<Object>?
I tried the following iteration with C#: var objects = List<Object>{ new {Id = 2, Nome = "Wallace"}, new {Id = 4, Nome = "Cigano"} }; foreach (var user in objects) { Console.WriteLine ("Meu id…
-
11
votes3
answers2766
viewsCount or Count()
Having a list, what better way to know the number of items on this list and what the difference? if (minhaLista.Count > 0) ; or if (minhaLista.Count() > 0) ;…
-
11
votes1
answer165
viewsLike, when and why use "Securestring" in C#?
I once heard about the class SecureString from C# and it seemed interesting to me, so I think it’s interesting content that can yield good answers from more experienced professionals. Some questions…
-
11
votes2
answers359
views -
11
votes2
answers1625
viewsLambda Groupby by year and month
I have a list of events, and I’d like to group them by year and month, for example [Year 2017] Month January { Event 1, Event 2, Event 2 } Month February { Event 3 } [Year 2018] Month January {…
-
11
votes3
answers17994
viewsWhat is the Difference Between HTML.Actionlink vs Url.Action?
Reading some tutorials of ASP.NET MVC I found these two helpers being used to do basically the same thing, which was to direct the user to a new view. So I wonder if there’s any more remarkable…
-
11
votes2
answers4107
viewsConcept of class, entity and objects
I’m reading about classes in C#, and an excerpt left me a little confused. I know that classes are objects in C#, and can be used in various ways. My doubt is in the following sentence: "A class can…
-
11
votes6
answers1056
viewsHow to make a Split for when there is a letter in the string?
I’d like to make one string be divided with the .Split() every time there was a letter. Example: To string: 97A96D112A109X115T114H122D118Y128 Would become a array with 9 values: { 97 96 112 109 115…
-
11
votes1
answer1173
viewsWhat is the difference between WCF and a Web Services?
I’ve always worked with Web Services, but lately I’ve seen a lot if you talk about WCF, hence my doubt. What’s the difference between WCF and a Web Services? Is there some improvement between one…
-
11
votes5
answers1059
viewsIs it possible to convert a 16-bit number to a single byte?
If I create the following expression: Int16 numero = 2017; byte m = (byte) numero; m will have the value of 225. Okay, how do I get 2017 from the byte m (reverse operation) again?…
-
11
votes3
answers649
viewsWhat is the Target Framework and what is it for?
I work for a while with .NET and I was asked about the target framework of my projects. I understand what it’s for but I couldn’t explain it simple and clear what exactly is.…
-
11
votes1
answer259
viewsHow to remove the last number from an integer?
How can I remove the last number from an integer? Ex: int value = 123456789; int newValue = 12345678; Note that the new value does not have 9. I know it would be possible to switch to a string and…
-
11
votes5
answers1530
viewsDo programs written in C# depend on the . NET Framework to run?
Once compiled a C# code depends on the . NET Framework installed on the machine to run, similarly to Java?
-
11
votes1
answer269
viewsWhat sort algorithm does . NET use by default in a list?
I have a problem that I have to perform sorting in memory of a high number of items and I would like to know which algorithm that the . NET uses to sort when we call the method Sort() from a list,…
-
11
votes3
answers663
viewsClass generic property
I have a class with two properties (Name and Value). The estate Name is a string, already the property Value I want to leave the variable type. public class Field<TValue> { public string Name…
-
11
votes1
answer332
viewsHow to know if path exists?
One of the classes of my system is created with the information of a file. When starting the system, it initially runs the following lines: public List<Estabelecimento>…
-
11
votes2
answers252
viewsDifference between instantiating class and using
I can instantiate a class in two ways in C#, they being: HttpClient http = new HttpClient(); or using (var http = new HttpClient()) { // } Is there any difference between these means? Performance?…
-
10
votes2
answers73740
viewsHow to access the print screen image?
When we hit the button Print Screen from our keyboard, the screen image is saved in some cache, in memory, somewhere, because when we give Ctrl V after, in Paint for example it trims, how to access…
-
10
votes2
answers151
viewsRelationship between Middleware and Application Delegate
I’m studying the OWIN and its implementation Katana by Microsoft. I’ve asked about it here and the answers already help to have a good overview of the subject. Going deeper I found this doubt. In…
-
10
votes1
answer358
viewsWhat are closures and what is their use?
The answer to this question on lambda What are lambda Expressions? And what’s the point of using them? talks about closures and Tree Xpressions, however, does not have a clear example of what they…
-
10
votes2
answers19497
viewsHow to get a snippet of a string?
I have a string like this: ~/Areas/Teste/Views/home/index.cshtml I just need the word that comes right after ~/Areas/, in the case Teste (remembering that this word may vary in size). How do?…
-
10
votes3
answers1631
viewsConcurrency control in database insertion
I have a competition control problem in entering data from a table. The scenario is as follows:: There is a table that records daily data according to user requests, and this data cannot be…
-
10
votes2
answers1467
viewsMethod to execute when destroying class instance
There is some way to execute a method automatically by destroying a class instance. I have a generic SQL class, where in the constructor I call a method that opens the connection. Only I want to…
-
10
votes3
answers667
viewsWhat are these attributes in the properties?
What are the names of these "attributes" and what are they used for? Examples: in the declaration of a class: [ComVisibleAttribute(true)] public sealed class SerializableAttribute : Attribute in the…
-
10
votes3
answers11142
viewsDifference between Console.Read(); and Console.Readline();
I’m starting to learn C# and I got a little confused by one thing. What’s the real difference between Console.Read(); and Console.ReadLine(); ?
-
10
votes2
answers16045
viewsForeach or lambda in lists
Which one do I get the best performance to get the value of a given in a list? I do foreach or lambda(when possible, of course)? I can have this: foreach(var i in lista) { var teste = i.NmCampo; }…
-
10
votes4
answers844
viewsHow to create properties dynamically in C#?
In Javascript it is easy to create an object with new properties. var obj = { "propriedade1" : "valor", "propriedade2" : "valor" } It is possible to do something similar in C#? var lista = new…