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
-
5
votes1
answer178
viewsWhat is an Appdomain?
I read about it on the Microsoft website. It would be interesting to have a succinct answer here in Portuguese with a summary of what is? There’s something important that’s not in the documentation?…
-
5
votes1
answer596
viewsPersonalize message by the hour
I wanted to personalize the greeting message depending on the time. Ex: Hora menor que 12h. "Bom dia" Hora menor que 18h. "Boa tarde" I did with if and else but wanted a better method. //Pegando a…
-
5
votes1
answer789
viewsUse Ienumerable or Icollection?
I want to create a 1 x N mapping using the Fluent API of Entity Framework, something like: a shopping cart has several products. In my class stroller, I have a navigation Property, which is a…
-
5
votes2
answers406
viewsTolist vs Typed Tolist
I was reviewing some methods of an ASP.NET MVC project and found some cases where it is used only .ToList() and others in which it is used .ToList<type>() (where type is an object type used in…
-
5
votes2
answers350
viewsHow to get the total memory occupied by the application?
I know there’s a GC.GetTotalMemory, but it only shows the consumption of managed memory. It has how to discover the full use of the application?…
-
5
votes1
answer593
viewsHow does seed influence the generation of random numbers?
The doubt is very simple, I would like to know how the class System.Random generates random pseudorandomness numbers from a seed, which I find odd. I know they are not totally random, and so I have…
-
5
votes2
answers83
viewsWhat is the syncblock?
I received a reply about a syncblock. Why is it necessary? I understand what I researched is about competition control. But why does every object need it if not everyone will have competition?…
-
5
votes3
answers119
viewsWhy declare property twice in one class?
When declaring a property in one class, they usually declare twice, one public and the other private. What is the purpose? private int _years; public int Years { get { return _years; } }…
-
5
votes2
answers146
viewsDeclaration of `var as object field
How could I declare a variable var public so that it could take the return of the data. How would the statement of these variables without completion: var tbuscar = ?; var retorno = ?; public bool…
-
5
votes1
answer574
viewsHow does the Type.Invokemember method work?
I came across this method in a code and was curious how it works because I’ve seen some applications running in C# that use this method, and when searching for the method in Google, I found no clear…
-
5
votes1
answer86
viewsHow to know which exception can be cast in C#?
If in Java I invoke the method void cadastra() throws SQLException for example, I will be required to add a block try catch or to "relaunch" the exception that can be launched by this method. That…
-
5
votes1
answer503
viewsHow to write an asynchronous method?
I have the following method: public void Contar() { int numero = 1; for (int i = 0; i < 100000; i++) { numero *= i } return numero } Supposing that the method Contar() take time to lock the UI of…
-
5
votes1
answer376
viewsWeb service hosting equals a website with pages?
I am developing a mobile application with Xamarin. This application is a screen to authorize or not discount above authorized by sellers. So I have a web service that goes into the bank and takes…
-
5
votes1
answer246
viewsCompatibility between . NET Core 2.0 and . NET Framework 4.7
I am creating general purpose libraries (Dlls), to reuse them in projects . Net Core 2.0 and . Net Framework 4.7. I wish to have projects. Net Core on Linux and projects . Net Framework 4.7 for…
-
5
votes1
answer917
viewsHow to use multiple App.config
How to use more than one App.Config? I have a Solution with several projects. In each project there is an App.Config. When I try to read a key, either by AppSettingsReader or by…
-
5
votes2
answers2000
viewsWhat is the difference between async Task and void?
I use async Task with await when I need my code to wait for such a task to complete until it performs another process. In the case of methods void, without async-await, my code also does not "wait"…
-
5
votes2
answers1451
viewsI need to know when the user uses semicolons in decimal numbers
I am developing an exercise whose result is different in scenarios that the user uses point or comma to put his decimal number, in this case I put as variable of type double…
-
5
votes1
answer362
viewsWhat is the best validation strategy before data persists?
I’m used to . NET using C# and Entityframework. And there in the Entity we have the dataanotations. When I create the entity in C#, for example person, just put the datanotaations and the Entity…
-
5
votes2
answers238
viewsHow to find reserved word in a sentence?
I am creating a routine to search reserved words in a text (name of people). I have tested with Contains() and IndexOf(). Works well most of the time. However in some words the return does not…
-
5
votes1
answer137
viewsConvert SQL query to LINQ
How would this SQL query convert to LINQ: "SELECT SUM(valor_negocio) valor_negocio, " + " MONTHNAME(STR_TO_DATE(MONTH(data_inicio), '%m')) mes," + " STATUS" + " FROM negocio" + " WHERE data_inicio…
-
5
votes2
answers260
viewsHow to save changeable parameters in the system?
I have an ASP.NET MVC project and I use web.config to save some parameters that will be used by the system, but should not be changed by any user. Now I have to implement some other parameters that…
-
5
votes1
answer100
viewsHow to use expanded property in C#
I have a problem, I created a class containing the following property: public class MinhaClasse { public int Idade {get; set;} } But when I do it: public class MinhaClasse { public int Idade { get{…
-
5
votes2
answers812
viewsGet previous element in foreach
It is possible to take an element from the previous to current position using the repeat loop foreach? For example, whenever I need to take an element previous to the current position of the loop, I…
-
5
votes2
answers3367
viewsWhat are the differences between Viewbag, Viewdata and Tempdata?
I was researching how to pass data to a view, or rather, persist the data of a controller to the view. I would like to know among the 3 forms cited in the title: What are the differences between…
-
5
votes2
answers139
viewsCan hashes be different for the same bytes?
I’ve found a flaw or I can’t deal with hashes. I have two bytes arrays random, one generated by an algorithm and one original. I am trying to make the algorithm EXACTLY the same as the original.…
-
5
votes2
answers211
viewsDifference in cast using "as" and "type cast"
A question arose about casting in C#, I see in many fonts using the cast in the following ways. What is the difference between one and the other, when using one way or another? public interface…
-
5
votes1
answer292
viewsIn Winforms how do the datepicker cursor walk when typing the date?
The question is about Winforms' Datetimepicker control. When we type the date, instead of choosing the calendar, the cursor does not walk. That is, we typed the two digits of the day, and instead of…
-
5
votes1
answer1303
viewsWhat are the scenarios in which C# has an advantage over other languages?
Here on the site have some similar questions, for example, What are the ideal use scenarios for Node.js? and Why choose C instead of C++ or C++ instead of C? I would like something in this sense but…
-
5
votes2
answers1346
viewsDifference between ADO.NET and Dapper
What are the differences between Orms? When to use one and when to use the other? What are the disadvantages of each?
-
5
votes1
answer663
viewsViews do not recognize @model, @Viewbag, @Viewdata
I am using Mono 5.10.1 and Visual Studio Professional for Mac (Version 7.5.4 build 3) Views do not recognize tags like @model, @Viewbag and @Viewdata, either in older projects that were originally…
-
5
votes4
answers283
viewsCreate list with more than one element as if it were multidimensional
I need to receive these pairs of data from the bank, and I’m thinking of a way to bring the values without creating an object, because I think it’s unnecessary in this case. It is possible to create…
-
5
votes2
answers279
viewsWhat is this "k_BackingField"
I have a project to create a C# Smart Device for Windows CE. I received a code result reverse engineering, but there is a part that I am not able to understand or adapt. Below follows the code:…
-
5
votes2
answers203
viewsWhen to use "Try catch" in layered application?
Let’s say I have my layers Controller Business Repository so it is necessary to create this block in the 3 layers or create only in the controller? If I do this she ensures that every code that is…
-
5
votes1
answer281
viewsIs Winforms dead now?
Windows Forms has been on the market for approximately 17 years since. NET Framework 1.0 released in 2002, and still remains one of the major limitations of running only on Windows, as its name…
-
5
votes1
answer672
viewsWhat are Mutexes and when is it advisable to use this feature?
I read about Mutexes and the class Mutex. However, I cannot understand clearly what Mutex is and what this class does. Since I would like to know if I can use this feature to prevent my desktop…
-
5
votes2
answers200
viewsWhat’s the opposite of . equals in C#?
I’m doing a left Join where I want to pick up just what’s on the left table and there’s no right one. I’m using LINQ and Entityframework. I made a code that takes the similarities, follows below:…
database .net entity-framework entity-framework-6 ormasked 4 years, 11 months ago Garota de Programas 57 -
5
votes1
answer151
viewsHow to avoid repeating "using" in ASP.NET MVC?
I have a controller where several moments have a code similar to this: public ActionResult ListarProduto() { using (DBModels db = new DBModels()) { return View(db.Produto.ToList()); } } How not to…
-
5
votes1
answer159
viewsHow to use methods contracts and why?
Reading a book on development . NET, I saw a brief description about methods Contracts and tried to know a little more on the internet. It uses an imperative syntax that is costly and has low tool…
-
5
votes1
answer146
viewsLINQ Lambda | Query Syntax VS Method Syntax Performance
Doubt regarding the construction and performance of querys using Query Syntax and Method Syntax / LINQ Query Syntax: var VendorQuery = from v in vendors where v.CompanyName.Contains("Toy") orderby…
-
5
votes1
answer107
viewsIf everything in C# inherits from Object, why aren’t all types by reference?
If, for example, a struct type inherits from the class System.ValueType (who inherits from System.Object), why it, and the other types by value, are not allocated in the heap? By making a Boxing, we…
-
5
votes1
answer78
viewsA method can access the properties of the object it belongs to when stored through a delegate?
I’m building a dictionary of the following kind: <string, delegate>, that will access a method belonging to an object of the following class: class Example{ public int Power { get; set; }…
-
5
votes4
answers1546
viewsTake specific value from a JSON or XML
Hello, I have an entire JSON inside a string and I need to turn it into an object in order to access some data... I’ll leave the code below to see if you can help me. My JSON is in that string:…
-
5
votes2
answers345
viewsHow does the rounding of the string format work?
Consider the following code snippet: decimal myValue = 3.045M; Console.WriteLine("Result by Math.Round = " + Math.Round(myValue, 2)); Console.WriteLine("Result by string.Format = " +…
-
5
votes1
answer122
viewsHow does Windows manage installation frameworks?
Today you were asking me how the management of frameworks on Windows. The new version is coming out .NET 5, that means I will have to install this version to install programs made with this version…
-
5
votes3
answers253
viewsCannot implicitly convert "decimal" type to "int" in C#function code
This code averages the arithmetic or weighted average of the 3 student grades based on your choice of average according to the use of the Equals, code error is exactly this conversion of decimal for…
-
5
votes2
answers156
viewsWhat is the correct way to do an Replace in a string-like variable?
I need to create a folder on the file server and realized that the variable that receives one of the information is coming with invalid characters ( / : * ? " < > |) for creating a folder on…
-
5
votes1
answer247
viewsAsync/await generates a new thread?
When reading about async/await methods, it is said that using these keywords alone will not cause your method to run in a new thread. However, I get the output below by running my code. A thread was…
-
5
votes1
answer91
viewsWhat kind of data do you use to store the date of death in a register (Datetime or string)?
I have a record of people where I need to store birth dates (DateBirth) and death (DateDeath). Knowing that the guy DateTime in C# cannot be empty and its default initial value is 01/01/0001…
-
4
votes3
answers249
viewsHow can I manipulate a PSD file to get the position of the layers?
I am working on a project where we have a file . psd (Photoshop) called "sprites" that contains all the icons of the site. I would like to get the positions of each layer to automatically generate a…
-
4
votes3
answers5030
viewsKeep zero after comma using the float type?
I have a database where product values are stored. When there is occurrence of numbers with zero after commas they come without zero. I did a test and with decimal it worked, but my application uses…