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
-
15
votes3
answers2510
viewsWhen not to return Task in async methods?
Normally, in some time-consuming tasks, I use asynchronous methods: public async Task myLongRunningOperation(int i) { ... } However, in what situations I don’t necessarily need to return a Task?…
-
14
votes3
answers30199
viewsHow do I round numbers to the nearest integer?
I have numbers double as double a = 0.4, b = 0.5; How do I round it up?
-
14
votes4
answers2252
viewsWhat is the advantage of hiding the class constructor in favor of a static method (no .NET)?
My leader uses this pattern in ALL his classes (I’ll give the examples in C#, but it goes for any . NET language): public class MeuTipo { private MeuTipo() { } // esconder o construtor public static…
-
14
votes2
answers3795
views -
14
votes3
answers13485
viewsChange the Datetime Timezone.
I am hosting my system on a server that is in the USA. So when using the DateTime.Now returns the date and time of the US. I would like you to return the date and time of Brazil. It is possible?…
-
14
votes2
answers352
viewsWhat does the operator = mean in C#?
I have a function in C#, where I decrypt a string and need to convert into a function in SQL Server for technicians to be able to work with the decrypted value. There is a foreach, I don’t…
-
14
votes2
answers511
viewsWhat are nesting guys for?
I know that C# supports nested types, that is, it is possible for me to declare one class within another. For example: public class A { // Propriedades e métodos da classe A public class B { //…
-
14
votes2
answers288
views -
14
votes6
answers2762
viewsHow to walk an Enum?
Here’s what I need to do: string and go through it and pick up each letter found and add with its corresponding value, type: a = 1, s = 19 and etc. Well, I made a enum with all the values of string,…
-
14
votes3
answers261
viewsWhat is the advantage of using the Set<> method?
What is the advantage or difference in using the method Set<> and I can do the same thing without him as in Alternative 2? Alternative 1 var aluno = contexto.Alunos.First(x => x.Id ==…
-
14
votes2
answers5656
viewsWhen and where to use a delegate in C#?
I’m new to C# and I still don’t fully understand the concept of using a delegate: public delegate void HTTPRequestsHandler(string url); I would like to know when to use them and in which cases a…
-
14
votes2
answers2969
viewsBillet generation in . NET
Until today I often imagined situations in which a system might need to generate boletos, although until now I have never developed anything like this, and so I decided to search how to do it in…
-
14
votes2
answers289
viewsNew C# 6 functionality "Auto-Property initializers" is just a facilitator?
One of the new C#6 features is the possibility to initialize properties at the time of declaration. public class Customer { public string First { get; set; } = "Jane"; public string Last { get; set;…
-
14
votes1
answer678
viewsIs . NET Core stable enough for production?
The . NET Core is already stable and reliable to the point of being used in production environments for commercial websites?
-
14
votes3
answers2118
viewsMemorystream vs Stream
What would be the main difference between the two? There are advantages to performance gain? For web use, which is the most appropriate? I’m using to "read" a array Byte[]: private void…
-
14
votes1
answer497
viewsShould I use the ushort, uint and ulong types whenever the number is equal to or greater than 0?
Is it good practice or is there something from Microsoft recommending the use of ushort, uint and ulong whenever I am sure that the value will be equal to or greater than 0? I can gain some…
-
13
votes3
answers2226
viewsPerformance: string "concatenated" or all in the same line?
I have a loop with thousands of results that renders a table. The string is mounted through Stringbuilder in this way (sample snippet): ScriptTbody.AppendLine("</select>");…
-
13
votes1
answer671
viewsVisual Studio 2010 lag
I’m a beginner in programming and got a very good study material for Visual Studio 2010. My question is whether this version of the package is too outdated compared to 2013. For now, I’m only…
c# .net visual-studio-2013 visual-studioasked 10 years, 10 months ago Ricardo Rodrigues Moreira 141 -
13
votes3
answers17303
viewsWhat is the best way to read an XLS file?
I would like to know the best way to read an XLS file in C#. I can handle it the same way I handle a database table?
-
13
votes2
answers141
viewsHow to Lambda in Extension Methods with Multiple Lists?
There are the following Objects: public class Objeto1 { public List<Objeto2> PropObj1 {get; set;} } public class Objeto2 { public List<Objeto3> PropObj2 {get; set;} } public class…
c# .net entity-framework linq lambda-expressionsasked 9 years, 7 months ago Jedaias Rodrigues 6,718 -
13
votes1
answer1813
viewsWhat is the difference between Action, Predicate and Func
What’s the difference between Action, Predicate and Func in the C#? I would like, if possible, examples of use.
-
13
votes1
answer718
viewsWhy should I use the Stringbuilder class instead of the String class?
Why these two classes are different, because it seems to me that they could be one class. For example, the method Append, it seems to me that he does the same thing as the operator +.…
-
13
votes2
answers241
viewsWhat is the purpose of the => operator in the use of lists?
What is the purpose of the operator => in the use of lists List<T>, I am starting to use generic lists and came across this operator, it is only used in this method LISTA.ForEach(i =>…
-
13
votes2
answers1019
viewsConvert.Tostring() and . Tostring()
Is there any glaring difference between them? Whether in performance or ways of dealing, what are their particularities? What would be the correct way to use (if there is any difference)?
-
13
votes2
answers618
viewsHow to list methods of a class in C#?
Again I have to say this: I come from PHP and am learning C# now. I usually like to list the methods that the class has, because I always did this in PHP, to test or debug. $a = new ArrayObject();…
-
13
votes3
answers1511
viewsHow can I replace a part of a string by itself plus the "~" character?
How can I replace a part of a string by itself plus the character "~"? I’m doing it this way: only when the string has two equal numbers as the 51 that comes just after AP and the contained in the…
-
13
votes2
answers2090
viewsWhat is the IL code and where can I find this code?
In my question about static builders the user Maniero showed how is the code generated from a static constructor by . NET, this code is called Code IL according to his reply. See the IL code of my…
-
13
votes1
answer832
viewsWhat are statements and operators?
I usually access the MSDN often and I see a lot of these terms. What are statements and operators? What differentiates them?…
-
13
votes3
answers569
viewsWhat are the consequences of programming in 32 bits or 64 bits?
It would only be the memory capacity that is limited to 4 GB in 32 bits? I need to have specific concerns? I know what’s different about C, I want to know about C#.
-
13
votes1
answer236
viewsIs it possible to interact a C# code with code external to . NET?
How to call code written in another language that is not part of . NET, for example the language C? How this interaction takes place? How to call native Windows functions?
-
13
votes5
answers453
viewsHow to separate "words" in Camelcase in C#?
How can I separate "words" into Camelcase using hyphen for example? String: string example = "CamelCase"; // CamelCase para: // Camel-Case and enumerator: enum Example { CamelCase }…
-
13
votes3
answers680
viewsHow do I read the output of a loop-based process? [C#]
Everything happens correctly to start the process, but when trying to get some kind of return of its execution through any of the available redirectors, be it input, output or error, the application…
-
12
votes2
answers6298
viewsHow to find the default printer and print plain text on a dot matrix printer on . NET?
We have a thermal printer that does not support printing graphic elements - in this case, I will have to send simple text to it. Considering that our application will run on several different…
-
12
votes3
answers16084
views -
12
votes1
answer267
viewsHow to unify redundant XML namespaces?
I have the following XML: <?xml version="1.0" encoding="UTF-8"?> <DataTable> <Columns> <DataColumn xmlns:i="http://www.w3.org/2001/XMLSchema-instance">…
-
12
votes1
answer1319
viewsHow to install a Windows Service without Setup?
I have a Windows Service project in Visual Studio in C#, however, I need to install this project from lines of code, without use the Installutil of console nor the Setup of Visual Studio. There’s…
-
12
votes2
answers949
viewsHow the "namespace" works in ASP.NET
I don’t know ASP.NET, but I had to support a very disorganized third party code by the way. I have a file xxxx.aspx that is in the folder /cp and have those calls: <%@ Page Language="VB"…
-
12
votes2
answers1480
viewsHow to edit a list in C#?
I want to edit a record of a client in which I can already register, consult and remove. But I have no idea how to edit just a few items without others being lost. class Program { static…
-
12
votes1
answer225
viewsDoes the name size of a variable affect your weight?
There’s a size difference between that: string packet1234 = "123"; And that? string packert1234556 = "123";
-
12
votes2
answers732
viewsHow to leave an invisible Tabpage inside a Tabcontrol?
How can I leave a certain invisible Tabpage inside a Tabcontrol ?
-
12
votes1
answer6642
viewsWhat is a memory dump?
What is a dump from memory? How it can help in the possible identification of an inconsistency in the code? How the analysis is performed?
-
12
votes3
answers3072
viewsHow to convert a string to List<int>
I have the following variable and would like to convert it to an integer list: string variavel = "1,2,3"; How to convert it to a list of integers?
-
12
votes3
answers14451
viewsTurn the first letter of a string into uppercase?
Example: I have a string "stack exchange", how do I transform your first character, getting "Stack exchange"?
-
12
votes2
answers437
viewsPerformance difference of Any() and Count()
When I need to check whether a Collection has or has not elements which of the two methods will be faster, .Count() =! 0 or .Any()? I’ve heard that the .Count() may be faster in some cases. But by…
-
12
votes1
answer3277
viewsHow does the Linq Aggregate() extension method work?
I just saw some examples that used the method Aggregate() of namespace System.Linq, but I couldn’t find any good explanation for how to use it. What does this method and how it should be used?…
-
12
votes4
answers595
viewsHow to create a variable where to access its properties via string?
I’d like to access by string the properties of an object: (EXAMPLE 1) var cor = casa["cor"]; var tamanho = casa["tamanho"]; Instead of accessing like this: (EXAMPLE 2) var cor = casa.cor; var…
-
12
votes1
answer162
viewsIs "Then" really necessary at the end of the If block?
The Visual Basic . NET compiler seems to ignore the reserved word Then, the one at the end of the block If. If (1 + 1 = 2) Then Console.WriteLine("Passou no teste.") End If And now, without the…
-
12
votes4
answers750
viewsHow to limit the resources used by the system?
I have a loop loop that makes several iterations and has in its scope calculations that require a lot of processing. The problem is that when executing the code snippet, the use of the processor…
-
12
votes3
answers7644
viewsHow to create a Datetime object that represents the last day of a given month?
On an object of the type DateTime, how do I get a new object object DateTime representing the last day of the month of the first object? var data = new Date(2017, 3, 1); // 01/03/2017 var…
-
12
votes2
answers815
viewsHow does the logic of Where in the Entity Framework work?
I’m studying C# and I just made my first query in the Database: using System; using System.Data.Entity.Core; using System.ComponentModel.DataAnnotations; using…