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
-
10
votes1
answer2093
viewsOWIN and Oauth What are they and how to use them?
I am seeing Webapi tutorials with authentication/ authorization and I came across these two concepts, although explained in the tutorials the settings are not clear. Even searching the web, the…
-
10
votes2
answers433
viewsKeep data between sessions
I have an ASP.Netet MVC project where I file a report that requires quite resource of the machine in question of processing. I have a Action that generates and another that returns the report data…
-
10
votes3
answers6925
viewsHow to send 2 Controller objects to the View in C#?
I made a query in the database in 2 tables and saved in 2 objects in the controller, but I can only send 1 object to the view. // Controller // Pego os dados do BD e salvo no objeto var objPessoa =…
-
10
votes1
answer3515
viewsWhat is Partial View?
Using the Controller I can return a Partial View, JSON, string and other things. What is a Partial View? Is it widely used in projects? Why use it?
-
10
votes2
answers455
viewsString Interpolation performs better than string. Format?
I use Resharper and a few days ago I started using some C# 6 features. In various parts of the code use string.Format() and I realized that Resharper suggests that these snippets be replaced by…
c# .net string string-concatenation string-interpolationasked 9 years, 5 months ago Jéf Bueno 67,331 -
10
votes3
answers1283
viewsRemove Saturdays and Sundays from Calculation
I have a project where I work with activities of a project, my activities have a certain time to be completed, but the project has to make the calculation only with administrative days. For example…
-
10
votes2
answers525
viewsWhen is it recommended that a class implement Idisposable?
I use the IOC standard in my project which facilitates the call of procedure type Resolver.Resolve<IPedido>().GerarPedido(), however, I did not want to leave "loose" in this way, I would like…
-
10
votes1
answer3282
viewsHow to compile the database to install together with a C#application?
I’m developing an application in c#, and I need to know if I can compile the database to install together with the application, I’ve seen something here talking about Sqlite, but I don’t know the…
-
10
votes3
answers821
viewsWhat is the difference between "decimal. Divide" and the traditional "/" in C#?
decimal a = 10/5; Returns 2 decimal b = decimal.Divide(10,5); Returns 2
-
10
votes1
answer658
viewsWhat tools are available for C#project installers?
I’m having trouble finding a satisfactory installer solution for my Windows Forms and WPF applications. What Microsoft makes available is flexible or I’m not finding? What do you use? What do you…
-
10
votes2
answers375
views -
10
votes2
answers4980
viewsHow to determine the last element of a list in a foreach?
Given any list, how to know if the foreach is in the last element? There are some ways to do this, the one I see most is to save the last element and check if the current element is the same, but…
-
10
votes2
answers367
viewsDifference between . NET Framework for Entity Framework
I have an Asp.Net MVC project that when clicking properties the following information is displayed: When opening the file packages.config I could see that other information: After all, what exactly…
-
10
votes2
answers551
viewsWhat is the point of an explicit C#interface implementation?
I usually use interfaces in PHP and I was able to do a similar example, only for tests, in C#. class MyClass : IWriter { public string Writer(string str) { return str; } } interface IWriter{ public…
-
10
votes2
answers229
viewsCan try catch be replaced by using?
I always used the blocks try, catch and finally when programming in Java, and when I switched to C# I noticed that some codes exchange the try/catch for using. Example: using (FileStream fs = new…
-
10
votes3
answers1653
viewsPicking up part of the phone
In the registration, the user registers his phone and this field is masked (99)99999-9999 and this is saved in the BD. if I want to use only the DDD of this, and the separate numbers, how should I…
-
10
votes2
answers513
viewsReflection C#, how does it work?
I’m doing some tests with Reflection, I made this code on the basis of trial and error, so I didn’t understand how exactly it works. This is the enum that I’m wearing: public enum TipoDoAmbiente {…
-
10
votes1
answer152
viewsSealed class, with private constructor, versus Static class
When "studying" this class, I checked that it is sealed and has the private builder: public sealed class Interaction { /// <remarks> /// CA1053: Static holder types should not have public…
-
10
votes1
answer339
viewsWhat allows a method to be intercepted in C#?
Interception of a method is a technique that can be used to execute a code snippet before executing a main action. That is, in a very simplified way this would also be an example of interception:…
-
10
votes4
answers271
viewsJavascript equivalent of "Date.now()" in C#?
Here speaks how to get milliseconds using Date.now();, that returns something like 1533144170651. Follows his documentation: The method now() returns the milliseconds since January 1 1970 00:00:00…
-
10
votes1
answer130
viewsFunctionality of ":" in C#
Recently I was developing a C# application with Visual Studio and I came across a somewhat unusual situation: public void Upload(object model) { FOO: var text = "teste"; } In the code, FOO: does not…
-
10
votes2
answers289
viewsWhen to use record or class on C#?
One of the novelties of C# 9 are the record types, I saw that one of the biggest differences between them and the classes are the methods .ToString() and .Equals() who has a different behavior. But…
-
10
votes2
answers197
viewsWhen to use Lazy<> from C#
Where is a good scenario to use the initializer Lazy<> of the C#? I ask this because I understand the concept behind the Lazy loading (delay the instance of an object to only when it is…
-
9
votes2
answers282
viewsIs there a way to save types not listed in Settings.Default?
In a Windows Forms application I can create configuration properties. However there is the type List<T> or Dictionary<TKey, TValue>. By clicking on "Browse" and searching on mscorelib…
-
9
votes2
answers2594
viewsWhat does it mean and how does an Enum work with the [Flags] attribute?
I was seeing how the class works FileInfo and came across an Enum: [Serializable] [ComVisible(true)] [Flags] public enum FileAttributes { ReadOnly = 1, Hidden = 2, System = 4, Directory = 16,…
-
9
votes4
answers2855
viewsHow to merge multiple text files into one?
Does anyone know how to select all text files from the same directory and join the information of all of them in just one final text file? Example: In folder X, I have files 1.txt, 2.txt and 3.txt.…
-
9
votes1
answer936
viewsIn the Entity Framework, do the Singleordefault() and Firstordefault() methods exhibit different behaviors?
What are the differences between SingleOrDefault() and FirstOrDefault(), and when to use?
-
9
votes2
answers717
viewsReceive variable value without passing parameter
I have the following method: private string toCamelCase(string text) { text = string.Format("{0}{1}",text.Substring(0, 1).ToLower(),text.Substring(1)); return text; } To use it I need to call it…
-
9
votes1
answer395
viewsConcat() VS Union()
What’s the difference between Concat() and Union() ? When to use Concat() and when to use Union() ? Can only be used in list ?…
-
9
votes1
answer8805
viewsSeparate string by number of characters
I’m developing a component to read the file sent by Dataprev with the list of monthly obituaries. This file is a TXT and every 210 characters is a different person. The documentation can be seen in…
-
9
votes2
answers1138
viewsWhy can’t the implemented methods of an interface be private?
When I implement an interface in my class, why your implemented methods cannot be private/protected/etc? And another question, when I implement an interface method explicitly, why can’t this method…
-
9
votes1
answer266
viewsProblem with Fast Colored Textbox (indentation)
I’m modifying an open source project created by Pavel Torgashov, called Fast Colored Textbox, and I’m having problems with the language VB in the editor, because methods and properties are indented…
-
9
votes1
answer515
viewsWhat are the pros and cons of the Task<List<Object>> implementation on List<Object>
What are the advantages between the two implementations below. Both return a list with multiple products (more than 1k): public Task<List<Product>> GetAllProductsAsync() { var query =…
-
9
votes1
answer2403
viewsWhat is Cultureinfo.Invariantculture?
I installed Resharper and on that stretch x.Id.ToString() he suggests changing to x.Id.ToString(CultureInfo.InvariantCulture). What is CultureInfo.InvariantCulture and why that way is better?…
-
9
votes1
answer22992
viewsAccess Mysql with C#
I’m creating a Form simple that has 3 TextBoxes and 3 buttons and I want to save the information typed in Textboxes in a table. I’ve already created the querys all within a class acessoBD, but I…
-
9
votes2
answers1919
viewsWhen should I use GC.Suppressfinalize()?
In . NET, under what circumstances GC.SuppressFinalize()? What are the advantages of using this method? Obs: I found answer in the SO-en: When should I use GC.Suppressfinalize()? As it had nothing…
-
9
votes1
answer1327
viewsDatabinding, Dataset, Dataadapter and Datagridview: What are they for, how to use and in what order?
I’ve been trying to learn how to use Datagridview control for weeks (yes, weeks). Connecting to the bank using the designer is very easy, but I want to do it by code and I can’t. I saw some…
-
9
votes4
answers810
viewsSQL LIKE clause does not work with Sqlparameter
Following the recommendation that the @Maniero fez in that question I decided to parametrize the darlings SQL of my program. Behold: private void btnConsulta_Click(object sender, EventArgs e) { if…
-
9
votes1
answer298
viewsFind slow point in code . NET
I need to analyze a code that is taking too long to execute, the method code is extensive and makes several calls to other methods, I was thrashing to try to identify the point of slowness, but so…
-
9
votes1
answer296
viewsWhat are Sockets? And how to develop in C#?
I have to develop a socket, but I don’t know what it is or how it works! I wanted to know what it takes to create a C#Socket, I am using Visual Studio as IDE.
-
9
votes2
answers2804
viewsWhat is the "connectionString" connection string?
What is after all to string connecting? In a string of connection what represents the data-source? And the provider name?
-
9
votes1
answer120
viewsDifferences between readonly Func<> and method
Forgetting a little questions like readability, what would be the differences between the following calls? readonly Func = (T1, T2) => { Return default(Tresult); } private readonly Func<int,…
-
9
votes2
answers228
viewsIs there any functionality similar to Assert (affirmations) in C#?
In languages like Python there is an assertion mechanism (assert) which aims to state whether an expression is true and, if there are failures, throws an exception. In most cases, I think it’s best…
-
9
votes1
answer832
viewsHow to copy a file from the network to my computer using C#?
I have a desktop application that needs to copy media files from a server, videos and images. The server is on the same network as the terminal on which the program will be installed. The problem…
-
9
votes1
answer325
viewsSetup.msi prompts the user to install . NET Framework 4.6.1
I have a *.msi package of a software developed by me, with the Visual Studio Setup Project. When a user tries to run the installation package on his machine and he has not installed version 4.6.1…
-
9
votes4
answers785
viewsShould I use a "Try-catch" to identify if a password is wrong?
On the screen of login, carry out the verification in the bank by means of a select, and I’m using the catch to capture this exception. It is correct to use the catch for that guy? if (Usuario !=…
-
9
votes2
answers354
viewsHow do C#properties work?
In Java I usually create private attributes and create methods getters and setters, on account of the encapsulation. I couldn’t quite understand how this works in the C#.…
-
9
votes5
answers819
viewsIs the rest of the code inside Try executed after finding Exception?
The rest of the existing code within a try is executed after finding a exception or jumps right into the code inside the catch(Exception e) try{ x = 10; //alguns erro de try catch x = 20; } catch…
-
9
votes1
answer273
viewsHow do I know that the sum of two double’s will be greater than the limit of one double?
Is there any way to know if a sum between two values in the format double will exceed the variable limit double? Example with integer: 2147483648 + 1. In this case it exceeds the limit of an…
-
9
votes2
answers477
viewsWhat types of resources are released in a "using" statement?
According to Microsoft documentation: The using statement provides a convenient syntax that ensures use correct of Idisposable objects. Source. That is, the interface Idisposable provides a…