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
votes3
answers1590
viewsHow to add or subtract a digit in the Textbox via a button?
I want to add to a number in a TextBox generating a digit when the user clicks the " + " button and subtracts when he clicks the " - ". For example: the random number was 2. If I click on +, 3…
-
5
votes2
answers213
viewsValue priority data ordering using LINQ
I have a "status" table with the following values: ID 1 = Ativo ID 2 = Novo ID 3 = Excluido How would you return a list of objects (that have the status object) prioritizing, coming first, those…
-
5
votes1
answer150
viewsWhat is the "class" restriction on a generic type?
In the line below: public class Tree<TItem> where TItem : IComparable<TItem> This line I’m creating the definition of type TItem where TItem implements the interface IComparable, i.e., I…
-
5
votes1
answer773
viewsWrite include date using Entity framework
I believe there was a misinterpretation, I’m posting the code to be better understood. I am using a project for my EF Repository is inside it I have: Note the doubt in //companySalvar.DATA_IND =…
-
5
votes2
answers676
viewsHTML element inside an Actionlink
Hi, I was wondering if it is possible to create an HTML element inside a ActionLink, for example: To create a link in a menu with ActionLink: @Html.ActionLink("Classificação Financeira", "Index",…
-
5
votes4
answers2109
views"Filter" equal records into a list by adding their quantitative
namespace ConsoleApplication10 { class Program { static void Main(string[] args) { List<Teste> lstTeste = new List<Teste> { new Teste {Codigo = 1, Quantidade = 10}, new Teste {Codigo =…
-
5
votes1
answer407
viewsHow to create a new configSections in App.config
I am working with an application that currently uses the section appSettings to obtain application settings through ConfigurationManager.AppSettings. But I would like a more complex structure for my…
-
5
votes2
answers395
viewsBehavior of parameters in the class constructor in C#
I have a question regarding the behavior of the parameters passed to the constructor of a class, they are by default ref/out or value? Searching on the behavior of parameters in common methods they…
-
5
votes1
answer1179
viewsError entering data into database, EF 6
I’m trying to input data into the database, but I have a mistake in doing the saveChanges(); after doing several times the context.add(), has happened after 500, 2200 and 5500 times. Error: The…
-
5
votes1
answer219
viewsHow to simplify code with Foreach List?
How to use the ForEach() of List in the implementation below using System.Collections.Generic; public class Program { public static void Main() { List<Pessoa> pessoas = new…
-
5
votes1
answer684
viewsIs it possible to use composite key for Entity Framework with Model First?
I have the modeling down and will need to map composite keys like the Embedded id of Hibernate, but in the Entity framework using the model first, it is possible ?…
-
5
votes1
answer1843
viewsTempdata C# doubt with MVC
I know that the TempData has its "life" maintained until it is used in the View. However, if I do it on two different controllers, the same one identified from the TempData, I’m killing and about…
-
5
votes1
answer1247
viewsStart Windows Service automatically
I created a Windows Service test, I have been researching and saw that to start it automatically you need to change the property StartType of the object serviceInstaller for Automatic, that the…
-
5
votes2
answers351
viewsUpdate data using LINQ
I read that LINQ should be used for queries, but in the context below, the best way I found to update was by using the let. var produtos = from o in orcItens join p in Produtos on o.Id equals p.Id…
-
5
votes1
answer6047
viewsWhat causes the 'System.Nullreferenceexception'?
Time or other the execution of my systems are interrupted by this error, when it happens, a if(atributo != null) It usually does, but it pollutes the code, "Oh, but this variable needs to have a…
-
5
votes1
answer73
viewsSerialization of exceptions
According to the msdn documentation, an exception should be serialized if it should be propagated outside the Assembler. In visual studio, I have a solution with some projects, among them a class…
-
5
votes2
answers4914
viewsHow to delimit a string field in c#
I have a string field for example address in the code. This address field receives a 60 character data. What I want is to delimit the address size so that it only receives 30 characters and not…
-
5
votes2
answers3095
viewsHow to pass variables from Controller to View in ASP.NET MVC 4.5?
I’m quite used to PHP MVC where I can pass the values to the view from the controller as follows: public function Index(Users user) { return View('index') ->with('user', $user); } Or to return…
-
5
votes3
answers1915
viewsRemove element from a vector in C# and don’t leave the vector with a blank space?
I need to remove an element from a vector with 5 elements, and cannot get empty space in the vector. I need to remove by index.
-
5
votes1
answer70
viewsProperty access modifier C#
I noticed that it is possible to sign a property access mode as private: public string Codigo { get; private set; } Or just ignore it: public string Codigo { get; } Is there any difference or…
-
5
votes3
answers10165
viewsRemove non-numeric characters from a string
Example: I have the following string "M1245D454" and I need to just leave the numbers on it. M and D are examples, I want to remove any non-numeric character. There is some function in C# or VB.NET…
-
5
votes2
answers109
viewsStore values in Hashtable
When I keep the value of this Hastable he makes me wrong. Follows the code: Hashtable ht = new Hashtable(); ht.Add("index", index); ht.Add("tipo", "1"); string tipo = ht["tipo"];…
-
5
votes4
answers5492
viewsDifference between two dates, ignoring weekend - working days only
I was looking for something similar, but unfortunately I found nothing. I found this solution that helped me a lot but is in Java. How to calculate the difference between two dates by ignoring…
-
5
votes2
answers89
viewsAccess internal C#/. NET code structures
You can access the internal structures of a C# core code or C System.Core do . NET? For example, how is the method implemented First()? Alerta alerta = query.First(); I wanted to see how it’s done…
-
5
votes3
answers419
viewsHow to turn a bool into int?
I’m trying to do the following: if the guess value (_TextValPalite) is enabled then it will check that this number is not different from a minimum value and a maximum value. Ex: between 1 and 10 I…
-
5
votes2
answers212
viewsDoes the user need to have . NET if I compile using Mono?
The user who will use my application needs to have the version of . NET on the PC? I saw in some topics on the internet talking about this advantage of Mono.
-
5
votes1
answer66
viewsParameterizing Dataset in C#
I created a search screen with a textbox, one button and a gridview. I would like the search results to appear on this Gridview but I can only do that with one Dataset. In this case I needed to find…
-
5
votes1
answer933
viewsFile . exe in Visual Studio 2015
How do I generate an executable running on any machine without . Net installed? The one in the briefcase bin/debug does not serve because he needs the . Net to run.
-
5
votes2
answers1642
viewsHow do you convert an Enum guy into a list?
Is there any way to convert a Enum in List? public enum TiposHospedagem { Casa = 1, Hotel = 2, Pousada = 3, CasaCampo = 4 } I’m trying to run the enum and add to the list, but the foreach does not…
-
5
votes2
answers4659
viewsComparing only the Datetime field date in C#
I only need to compare the date of two fields DateTime. DateTime aux = new DateTime(2016, 09, 02, 10, 0, 0); if (aux.Equals(DateTime.Now)) { //Alguma ação... } In the code above, I need you to enter…
-
5
votes5
answers5699
viewsHow to get the current iteration index of a foreach?
Usually in order to get the current iteration index within a foreach, I do it this way: int i=0; foreach (var elemento in list) { // Qualquer coisa i++; } I believe there are other methods to get…
-
5
votes3
answers219
views -
5
votes3
answers287
viewsOut Of Memory when running a Getfiles in a very large directory
Currently I have a directory with several subdirectories that have more than 3 million files. I need to map only the directory where these files are. And this mapping should be separated by the file…
-
5
votes5
answers29254
viewsHow to convert date to dd/MM/yyyy format?
After I published my app, I started to receive the dates in the American format like this:9/14/2016 12:00:00 AM How to format to dd/MM/yyyy? I tried to convert.ToDateTime() more does not work.…
-
5
votes1
answer96
viewsCatch the time on a remote computer using C#
Is there any method for me to recover time and date from a remote computer using C#?
-
5
votes2
answers379
viewsHandle 404 error without using Try/catch
I have the following code snippet that makes an HTTP request, only that sometimes the URL does not work, then will be launched an exception by framework. HttpWebRequest request =…
-
5
votes1
answer195
viewsWhat are the differences between the following Caps and when to use each one?
Casting [...] process where an object type is explicitly converted to another type, if conversion is allowed. Source: Stackoverflow in Portuguese Assuming the following situation: var i = 10 What…
-
5
votes2
answers651
viewsDifference is between Backgroundworker and Task.Run()?
Usually when I had to do some operation on background, mainly involving progress bar update or Labels I used to use the BackgroundWorker, with your events WorkerReportsProgressand DoWork. I recently…
-
5
votes2
answers203
viewsDocumentation on WPF with pure C# code
WPF is what’s "new" for development, not only desktop but also mobile. However, almost all material that is available on WPF is fully tied to the use of IDE and XAML. But XAML is an intermediate…
-
5
votes3
answers1521
viewsHow to Put Music on Console Aplication with C#
I’m creating a game in C# (Aplication console) and I need to put a background music, as I do?
-
5
votes2
answers2900
viewsCustomize Messagebox in C#
I got the following MessageBox MessageBox.Show("Deseja iniciar a forma automática?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question) I can personalize it? Instead of being the buttons…
-
5
votes1
answer110
viewsAllow new conditions to be added without modifying code
I am manipulating a .txt and I have to exchange values like M31 for T90 for example. My code is like this at the moment: //Change machine tools for Sodick if (_strLinesFinal.Contains("M50")) { _OS =…
-
5
votes2
answers190
viewsSystem modularization
I’m developing a C# system with Winforms from Livestock Control to a farm, and will communicate with a scale to improve the weighing process. Some of the features are (Bill entry, vaccination,…
-
5
votes2
answers131
viewsMysql DATE type is displayed as DATETIME on a datagrid
I create a very simple database with the following command: CREATE TABLE IF NOT EXISTS `ABC`.`Socio` ( `idSocio` INT NOT NULL, `SocioNome` VARCHAR(45) NULL, `SocioDataNasc` DATE NULL, PRIMARY KEY…
-
5
votes2
answers226
viewsWhich . NET should I use?
I will start the development of a program with C# using Winforms (Basic Calendar with Mysql) and it is my question which framework utilise. This program can be made available on other computers and…
-
5
votes1
answer135
viewsWhen and why use the Obsolete attribute?
At least in the projects I’ve worked on, I see no point in using the attribute Obsolete in methods that are no longer used. What I do, and I see people doing is removing or commenting on codes that…
-
5
votes1
answer150
viewsLog with historical debug (Intellitrace)
I have a WPF application and am looking for the best way to solve untreated exceptions. Today, when an unexpected exception occurs, deal at the event Application.DispatcherUnhandledException. There,…
-
5
votes1
answer1683
viewsHow to identify and avoid memory Leak in . NET?
I know CLR has tools like Garbage Collection, responsible for memory management in .NET. One of the functions of the garbage collector, GC, is to avoid unnecessary memory consumption. Even with the…
-
5
votes2
answers2603
views -
5
votes2
answers252
views