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
-
5
votes1
answer482
viewsASP.NET Identity and Web API - Problem to register new user
I have a Web API project and I’m using Identity to manage user accounts, my controller is like this: public async Task<IHttpActionResult> Register([FromBody]RegisterDto model) { if…
-
5
votes1
answer129
viewsMultiple component events in one method
I have several events of my textbox, the problem is that I have about 30 in my form. I wonder if there is any way for me to improve my code, reduce it by creating only one method to control all…
-
5
votes2
answers1027
viewsCenter image in Nav menu bar
How do I center an image in the Menu bar? When I talk about centering, I mean not the image in the middle of the bar, but whatever position it is in, that has the same "measurements" for the top and…
-
5
votes1
answer151
viewsIs there a way to name the selected tables from a stored database to identify them in the Dataset?
I have a Store Procedure in SQL Server that projects various data. Example: CREATE PROCEDURE [dbo].[teste_sp] AS BEGIN select * from compra select * from cliente select * from fatura END However,…
-
5
votes2
answers998
viewsRegular expression, taking values from HTML
I have an HTML that I need to remove values from a set of <li>. This is the HTML part: <ul id="minhas-tags"> <li><em>Tagged: </em></li> <li><a…
-
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
votes2
answers305
viewsOnly constructors without parameters and initializers are supported in LINQ to Entities - Asp.Net MVC
I’m developing an application that manages courses. The student, when entering the registration screen and clicking on the "registration" button, is associated to a course, that is, is enrolled. So…
-
5
votes2
answers543
viewsHow to organize the return of data in a List<T>?
I have a wcf that returns me some information, I would like to bring them organized, how could I do it? I’d like to return data like this: At the moment it’s like this: I’m doing like this: public…
-
5
votes1
answer841
viewsAdd Migration and update at runtime Entityframework
I am developing an application and the need arose to add Migration and run the update at runtime. I already have the whole part that loads the modules: public class ClientContext : DbContext {…
-
5
votes1
answer305
viewsMonetize Unity 5 games on Windows Phone 8.X
How do I display ads in my game made on Unity 5 to the platform of Windows Phone 8.X?
-
5
votes1
answer4598
viewsGenerate Danfe from Nfe XML
I’m developing an application ASP.NET MVC with C# and need to transform XML from NF-e to Danfe in PDF, someone knows some component to it?
-
5
votes1
answer90
viewsVisual Studio or Eclipse Code Review Rule
I wonder if there is any add-in for visual studio that ensures that while I am in development environment make some changes but when I generate the build of the project, this commented part is…
-
5
votes3
answers11042
viewshow to Fill a Dropdownlistfor
Could someone help me how do I fill one DropDownListFor? Before I was doing it this way: @Html.DropDownList("lstAffiliate", string.Empty); But I saw that it was not recommended, then I decided to do…
-
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
votes1
answer44
viewsEntity Framework 6 error logging in Sqls
I’m trying to see the Sqls run by Entity Framework, use version 6. I’m following this guide. I made a new Dbcontext using the graphical interface. 5 tables only. The code is inside an API2 Web…
-
5
votes1
answer752
viewsError with Asp.NET Web.API + Angularjs
I have my method C# thus [ResponseType(typeof(Categoria))] public async Task<IHttpActionResult> Post(Categoria model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if…
-
5
votes1
answer1588
viewsCalling Asp.net application via HTML page
I have an app that I can’t change the source code that generates purchase orders. For each request an html is stored with the request data. I want to implement this html with the following: When…
-
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
votes3
answers185
viewsIfs and Object Orientation - C#
I have a question about how to replace IF with polymorphism. I will give the following example: Let’s say I have the classes ExecucaoIndividual and ExecucaoGeral. For this I created an interface to…
-
5
votes2
answers954
viewsExhaust character
I’m having trouble understanding the escape characters, I already know that the \n break line in a string, but the other characters could not understand. Ex: \a \b \f \r \t \v, found the…
c#asked 8 years, 7 months ago Samuel Renan Gonçalves Vaz 720 -
5
votes1
answer679
viewsDoubt with mvc list editing, using checkbox and editable field
I’ve got a lot of doubt and I barely know where to start, so I’m going to go to college: I have a page cshtml (I’m using Asp.net-mvc). It has a list, assuming that the elements are A, B, C, D, E.…
-
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
answer1818
viewsHow to make a placeholder in a Textbox?
How can I simulate a placeholder using WPF? Something like the input HTML where you click in the field it adds the text and when you change it returns the text? Remembering that it is in WPF,…
-
5
votes2
answers209
viewsCreate Fibonacci in a linear function with delegate
Using a list for the Delegate(I learned it’s called linear function, is that right? ) I decrease the list to get the respective values, but I can’t do a simple arithmetic operation with "X", because…
-
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
votes2
answers194
viewsWindows Universal Apps C++ vs C#
What’s the difference between C# and C++ to develop universal apps? I saw that in the templates of Visual Studio 2015 for C++ there is a group Cross Plataform with app templates for android and Ios.…
-
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
votes1
answer3359
viewsError; Connection has not been closed. Current connection status opens Sqlserver 2016
I am creating an application in visual Studio in C#, and when connecting to sqlserver in Server Explore, everything was correct in connection test. This is my connection string: return "Data…
-
5
votes3
answers899
viewsConvert data c#
Good people I’m having a problem with my code. I in my database have a field like date Only that after calling him to the program he also passes me the time , is something of the genre: 18-03-2015…
-
5
votes3
answers1037
viewsWhere dynamic Linq to SQL
I need to build a clause where with the field and dynamic value, for example, in pure SQL would be: WHERE :CAMPO = :VALOR However, searching the research I could not find anything specific, I’m…
-
5
votes1
answer301
viewsTwo dependent combobox using Linq to sql
How do I fill two combobox’s with Linq to sql where in a combobox for example I have countries and in another I have cities? How do they automatically change the values? I leave the image below how…
-
5
votes1
answer144
viewsCancel Doubleclick on Treeview
I am using a TreeView to control permissions on my system, each operator has a profile that determines their minimum access, but it is possible to give more permissions to a particular operator,…
-
5
votes3
answers269
viewsHow to format the name of an item in a listbox?
I have a project where I have to send files over the network to a server. When I click on the "add" button a box opens for the person to select the files they want to send and adds to a list that…
-
5
votes1
answer435
viewsC# IF simplification
I have this code, and I’ve been searching for a way to simplify it using a ternary operator, but I’m not getting it because it says I can’t use decimal string: decimal per; if (nud_qtPedida.Value !=…
-
5
votes2
answers296
viewsHow to make a LINQ/lambda and consume it in the view?
I have an object called Radio: public class Radio { public int RadioId { get; set; } public string StreamUrl { get; set; } public bool Ativo { get; set; } public bool Mp3 { get; set; } } I’m doing a…
-
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
votes1
answer283
viewsFill Combobox with Dapper
I’m using a component of combobox with the Dapper, but I’m not able to fill the combobox properly, follow code excerpt: LookUpEdit ctlControle = (LookUpEdit) pr_Controle; var parametro = new…
-
5
votes1
answer75
viewsIs it possible to hide a public method from the abstract class?
I have the following scenario: public abstract class ClasseA { public string[] MetodoC(string parametro, string nomeObjeto) { // ações metodo } } public class ClasseB : ClasseA { public string[]…
-
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
answers2406
viewsAccess content from another project in the same Solution
Here’s the thing: I have a Solution with two Projects, one Administrative and one Website, both using C# and MVC4. In the first project I save images and files in a folder Documents, and when…
-
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
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
votes2
answers887
viewsCalling a string equivalent method
Consider the following class: public class AnimationManager : MonoBehaviour { public GameObject[] Enemies; void OnTriggerEnter2D (Collider2D o) { if (o.tag == "Player") foreach(GameObject Enemy in…
-
5
votes1
answer210
viewsChange the quality of a video stream c#
I need to change the quality of a video that is being aired by my Api, I’m already sending the file, now I need to change the quality of it at the time of transmission, follow my code below: var…
-
5
votes1
answer570
viewsWhat is the difference between Ajax.Beginform and Html.Beginform in Asp.net MVC
Working with web inasp.net mvc, I saw that it is possible to use Ajax.BeginForm() and Html.BeginForm(). What is the difference between the Ajax and that of Html?…
-
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
votes2
answers2359
viewsPassword encryption
I have an Asp.Net MVC project and would like to securely store users' passwords in the bank. The goal is to create something that cannot be easily decrypted in a few hours of brute force on a PC (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
votes1
answer1418
viewsWhat is the correct way to use Bcrypt?
I’m trying to give my system a satisfactory level of security. In my researches I found several functions that create hashs for passwords, but among all of them, I saw the most recommended were…