Most voted "c#" questions
This tag should be used when the question refers to some resource, information or problem related to the C#language. C# ("C Sharp") is a multi-paradigm programming language that has strongly typed variables, is imperative, declarative, functional, generic, object-oriented and component-oriented, which are designed to be executed in . NET Framework.
Learn more…13,899 questions
Sort by count of
-
6
votes2
answers1675
viewsTranslating Identity in English
I’m using the Identity on my application MVC 5.2.3 Microsoft.AspNet.Identity.Core 2.2.1 also installed the translation package of the same Microsoft.AspNet.Identity.Core.pt-br 2.2.1…
-
6
votes2
answers245
viewsHow to fire multiple exceptions?
foreach (Foo el in arr) { // ... Validate(el); // ... } In the example code, when the foreach is executed, an exception can be triggered from the function Validate which will be treated on who…
-
6
votes1
answer793
viewsWhat is the use of Task.Yield?
The documentation of this method says: Method Task.Yield() - adapted from English Creates a task suitable which returns asynchronously to the current context when awaited. I read the his source code…
-
6
votes3
answers1105
viewsApp being recognized as potentially dangerous
I usually copy the exe of the way: C: Users Username source Chatwinforms Appname bin Debug Appname.exe But when sending it to my colleagues for testing, the browser says that the file is usually…
-
6
votes1
answer102
viewsHow does Visual Studio’s Edit and Continue work?
Visual Studio allows you to edit C#, VB.NET or C++ code in debug when you hit a breakpoint or click the break button (pause icon). The name of the tool is Edit and Continue. According to the…
-
6
votes1
answer149
viewsHow do I set the file size in a Download response?
I have an application where I give an answer by downloading a certain file on the server to the client. I zip the image files that are in a folder on the server and give an answer by manipulating…
-
6
votes1
answer272
viewsSort list by string resemblance
I have a list of string: AAA BBB CCC ABB ABC ACC ACD The user will type what he is looking for, would like to take to the first positions, the most similar. Example: String: A Upshot: AAA ABB ABC…
-
6
votes2
answers6385
viewsWhat does the HTTP Error 403.14 mean?
Well, I have a Web Api, which is configured as follows: WebApiConfig.Cs public static class WebApiConfig { public static void Register(HttpConfiguration config) { // Web API routes…
-
6
votes2
answers2606
viewsCheck whether the previous day is a holiday and/or Sunday
I’m having trouble developing a date validation logic. The variable dataFecha is called with -1 day to already validate the previous day. But when I go to test the validations, he did not subtract…
-
6
votes1
answer873
viewsEntity Framework Update Database
When executing the command Update-Database I have the following error Could not load file or Assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, Publickeytoken=b03f5f7f11d50a3a'…
-
6
votes2
answers905
viewsHow to create a sequential number that does not repeat, per user
Work on a bill issuance project, in this project exists the entity Emissor. My database Sql-Server may have several emitters. Each issuer can issue their tax bills. Each invoice shall have a…
-
6
votes2
answers198
viewsWhat are the advantages of creating dll’s in the project and not putting the classes directly into it?
In the company where I work use many DLL’s and I have a lot of difficulty debugging and understand this... In my projects (personal) I always put the classes directly in it and do not do as they, I…
-
6
votes2
answers1375
viewsHow to use DTO in ASP.NET CORE + DDD
I am assembling an application following the DDD standards. I would like to know how to properly use the Data Transfer Object - DTO standard. With the little I’ve read, I’ve come to the conclusion:…
-
6
votes3
answers519
viewsHow does C# run on other platforms?
As a complement to this question, run C# on a system where . NET Framework is native, it is default to run the application executable. As far as I know, C# depends on the . NET Framework to be…
-
6
votes2
answers782
viewsHow to create a Restful API with asynchronous processing and response using C# + Angular(v5+)
Hello, I am working with C# and I have the following problem: Imagine I have a route to my API api/estoque/inventario where this route should make the calculation of the inventory of the entire…
-
6
votes1
answer196
viewsWhat is the difference between performance between different types of string concatenation?
I know 4 different types of concatenation of string in the c#: // string Interpolation $"valor {variavel} R$"; // Verbating string @"texto qualquer pula a linha e continua o texto"; // concatenar 2…
-
6
votes0
answers272
viewsFetch the certificate from the client, not from the server
I need to get the certificate, and I would like you to search the client, not the server, I try to do this way: public static X509Certificate2 EscolherCertificado(string serial) { var store = new…
-
6
votes1
answer108
viewsHow to reflect on overloaded operators in C#?
My problem is this: I’m writing an interpreter and I need to perform dynamic operations between various types. For this use dynamic links provided by DLR consisting of a static object encapsulated…
-
6
votes2
answers236
viewsRemove unwanted characters from a List<string> without going through the list
Be the following excerpt a Windows Forms application. List<string> lista_strings = new List<string>(); for (int i = 0; i < 2000; i++) { lista_strings.Add("TST1234"); //preenchendo a…
-
6
votes3
answers820
viewsHow to exit the FOR loop within the Switch structure?
I’m in a noose FOR and I want to lock him inside the Switch, but when I give break within the Switch he comes out of Switch and continues the loop FOR, someone can tell me how to get out of the loop…
-
6
votes1
answer67
viewsIs there a correct way to pass parameters to search?
I am making a Restfull application and it occurred to me the following doubt: "Am I passing parameters in the correct way for this method?" The method in question is this:…
-
6
votes1
answer99
viewsWhy do typed accessors run the process faster?
I was reading an article by how to improve the performance of a Reader data using ADO.NET and in this article he cites the use of Typed Accessors to perform this function, from what I understand it…
-
6
votes3
answers1299
viewsShould every table have Primary key?
I believe my question is both conceptual and technical. My whole problem started when I made an SQL Server database and in it there were some tables without primary key, such tables would serve…
c# asp.net-mvc sql-server entity-framework entity-framework-6asked 5 years, 3 months ago Nelson Francisco 147 -
6
votes2
answers108
viewsLine breaking problems and correctly display real value conversion on C#
I made a simple C# code that asks you to enter name, age, weight, city and state, performs normally only that it appears some problems as instead of the weight being 60.5KG gets 605KG and wanted to…
-
6
votes1
answer219
viewsHow does the . NET "using" and Garbage interface work?
In a reply now deleted here on the site it seems that there was some confusion with the content indicating the use of GC.Collect() and how the using C# works. So how does it actually work using and…
-
6
votes3
answers142
viewsMultiple cases on switch with C# 8
On seeing this question about multiple conditions in the switch, reminded me of a problem I had and I couldn’t solve. In C# 8, a new syntax for switch: int num = ObterUmNumero(); var descricao = num…
-
5
votes2
answers961
viewsHow to redirect from non-www to www?
I want my website visitors to always access with www. I want to somehow redirect in case the user tries to enter without www or Ubdomain. If you try to access exemplo.com I want to redirect to…
-
5
votes1
answer839
viewsWPF - The Selecteditem property, from Combobox, is not working properly
Note: This question was the translation adapted from the original question, so all the Updates of the original question are together in this text, sorry for that, but the time is short and I can’t…
-
5
votes2
answers879
viewsHow can I prevent a user from submitting the same form multiple times?
I have a form on a page, sometimes users can double-click the button to submit the form... The form is a @using (Ajax.BeginForm(...)) { } How can I prevent that from happening?…
-
5
votes3
answers1977
viewsHow to delete a file marked with the "Read only" attribute?
I am trying to delete a file that is marked with the attribute "Read only": Whenever the file is marked with the said attribute, I get the following exception: System.Unauthorizedaccessexception was…
-
5
votes9
answers2644
viewsBest practice for creating if
Which of the two code options has better performance? I’m going to show you a very simple example, usually there’s more code inside the if. To) string mensagem = "OI"; if(exibirAdeus) mensagem =…
-
5
votes2
answers147
viewsIs there in the framework . Net, any delayed reading class?
I wonder if in . Net there is some class that allows me to tell her how to read a data, but that DO NOT read immediately... only later when requested, this class reads and stores the value, in case…
-
5
votes2
answers3054
viewsHow to use special characters in strings?
What are the characters for ~ and @ in the string of path in ASP.NET. Example: StreamReader srFile = new StreamReader(@"\\server\pasta\arquivo.html");…
-
5
votes2
answers1593
viewsHow to register dll . net using Inno Setup
I have a DLL written in C# and can’t register it using Inno Setup. An example of how to run this process would be useful.
-
5
votes4
answers3081
viewsLimit number of characters per line
It is possible to limit the number of characters per line of a textbox multiline using Windows Forms C# and . Net 3.5?
-
5
votes3
answers19154
viewsHow to take the path of the open executable in C#
How do I take the path of the project in c#? Is there any function? Or I have to write the full path on my application?
-
5
votes1
answer190
viewsParameter for Stored Procedure not identified
I’m having a problem, which would be a mistake saying that there is no parameter being passed to the Procedure. It is running the following code: cmdProcedure.Parameters.AddWithValue("@id", 0);…
-
5
votes3
answers2713
viewsASP.NET MVC5 - Asynchronous Methods in Controller
I’m developing an MVC layer for an ASP.NET system written initially in Webforms. It does not use Entityframework, so a good part of the system I had to elaborate a home solution. In order to use the…
-
5
votes3
answers593
viewsFind string in more than one SQL table
I would like to search for a certain string using LIKE in more than 1 table. Here is an example of how I did, which will probably spend a lot of time or will not search in all tables: string SQL1 =…
-
5
votes2
answers351
viewsHow to recover from an Exception and send data from it?
I wonder if there is any way for when my system launches some kind of Exception it recovers only and sends me an email stating where it occurred and which Exception was launched!
-
5
votes1
answer372
viewsHow to resize thumbnails generated by Uploadfy? ASP.NET c# MVC 4
Hello, I would like to know how to resize the thumbnails generated by jQuery Uploadfy plugins. As shown in the print below, it generates the thumbnails according to the actual size of the images, it…
-
5
votes3
answers844
viewsComparison of >= and <= with strings
I have a field in the database which is in the following format: YYYYMM Using the past I can normally search these fields: WHERE I.DT_INCL >= @inicio AND I.DT_INCL <= @final When trying to…
-
5
votes3
answers523
viewsDynamic display of mandatory, optional or non-existent fields
There is a class that has 12 properties, which in its insertion in the database may be mandatory, optional or non-existent, depending on the business rule specified in the registration of another…
-
5
votes3
answers1456
viewsEncapsulate values returned by JSON within a single object
I have a question, I have this code below on controller: [Authorize] public JsonResult Teste() { var licencas = new List<Object>(); licencas.Add(new { Responsavel = "José", Ticket = 79007,…
-
5
votes1
answer2001
viewsHow to List Users with Asp.Net MVC 5
I am using Visual Studio 2013, I am creating a new Asp.NET Web Application project using MVC and authentication by "Individual User Account". I would like to know how to list all registered users.…
-
5
votes1
answer125
viewsHow to show correct name on an Enum bitwise?
I have this one marked as [Flag], ie, are values in bit [Flags] public enum Position { None, Left, Right, Both=3 } Setei to Both(both) position in 3 why if it is Left and Right at the same time, it…
-
5
votes4
answers4168
viewsConvert string to Time
I got a column in the database that gets a guy varchar which corresponds the hours on my app ("HH:MM"). I need to convert this string to a type TIME and then concatenate with a type DateTime.…
-
5
votes3
answers266
viewsWPF - Datagrid - Exclusion
How can I get the index of a selected item on my Datagrid in WPF? I know in WEB Forms I can get it like this: MainGrid.Rows[e.RowIndex].Cells[0].Text
-
5
votes2
answers318
viewsIn an architecture, does the number of Dlls influence performance? Scalability?
I have the habit of creating my Solution like this: Entity - Class Library (Classes, entities) Utils - Class Library (Classes of support, security, generate xml, in short, all kinds of functions)…
-
5
votes3
answers2753
viewsCreate and read DLL in php?
It would be possible to create and open windows DLL libraries in php? I want to organize my php classes into dll so that they can be used in both php and C#, if there is an alternative also serves.…