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
-
7
votes2
answers548
viewsMemory error when entering millions of records using Entity Framework
I am using the Entity Framework to Insert and Update Thousands of Records. At first it was slow, but after putting the code down it improved the speed. db.Configuration.AutoDetectChangesEnabled =…
-
7
votes2
answers3200
viewsCode protection . NET
I have a C# application that I developed, it will be installed in several clients. The problem is that I have to protect the application code, because I performed some tests with the Ilspy…
-
7
votes2
answers5391
viewsHow to update an item from a generic list?
I am trying to change the name and email of a particular item in the list below, but I couldn’t find another way to remove the item from the list and add it again updated. There is another way to…
-
7
votes1
answer3337
viewsSend data to controller via Json
I am trying to send via Ajax some data from my form. In this form, I have fields inputs normal and a list of vendors I previously selected via checkbox. Follow screen: I am creating the JSON object…
-
7
votes2
answers9136
viewsCreate static Selectlist and pass a selected item to the View
I’m having a question about how to send my selectList "status" to my View EditarUsuario. I created my list with the following items: var list = new SelectList(new[] { new{ID="2",Name="Selecione"},…
-
7
votes2
answers355
viewsHow to use Windows Forms components in a WPF application?
Is there any way to use Windows Forms components in WPF? For example, I need to use control Chart or the MaskedTextBox from Windows Forms, which does not exist in WPF applications, as I could use it…
-
7
votes2
answers2134
viewsWhich loop is faster for or foreach in C#?
I’ve read articles from some programming languages that loop for is faster than the foreach, and wanted to know if C# has performance differences?
-
7
votes1
answer589
viewsModify visual element by another thread
I want to define by a Thread the content in a Richtextbox but I get an error saying Cannot make calls from another thread distinguished from the same Textbox I have heard that it is possible to use…
-
7
votes1
answer104
viewsProblem with . Include() in Entity Framework(Postgres)
I’ve been having a problem with Entityframework, it’s as follows: When I use the ORM(.Include) string to give a Join in tables with foreign keys, it automatically changes the name of the keys in the…
-
7
votes1
answer8641
viewsError in Assembly reference
I am trying to add a reference to my project, but when I add and run the project it presents this error: Unable to load file or Assembly 'Waitwindow', Version=1.0.6164.26027, Culture=neutral,…
c#asked 7 years, 10 months ago Jeremias Santos 189 -
7
votes2
answers749
viewsTable does not appear in EDMX models
I have a problem in an application I am developing, I created the models using the ADO.NET Entity Data Model. However a specific table is not appearing follows below the script I am using to create…
-
7
votes2
answers1872
viewsError: The name 'Viewbag' does not exist in the Current context
Good morning, I have projects using System.Web.MVC na versão 4.0.0.1, worked normally in the 2013 version of Visual Studio, now I’m trying to work with Visual Studio 2015 and my Views no longer…
-
7
votes1
answer153
viewsWhat is an equal input parameter (allocation operator)?
I have a function defined as follows: public classeDeRetorno nomeDaFunção(string param1, string param2, string param3 = "") What does the param3 = ""? It equals the parameter to ""?…
-
7
votes3
answers566
viewsSame types but with different objects. What is the best way to use it?
I had to create a new object but totally the same as the one in the C#system. Since the objects are the same I tried to do: ObjetoOriginal.Propriedades = ObjetoClone.Propriedades; Unfortunately it…
-
7
votes3
answers2045
viewsInserting record and recovering ID generated by SQL Server 2012
I want to insert a record into a table, recover the ID that was generated by AUTO_INCREMENT and insert records into other tables using this ID. But, I want to do this all using the BeginTransaction.…
-
7
votes2
answers3355
viewsSearch item in a list using LINQ
I have a list and want to search it (as if it were a database). It is possible? Ex: list all names from the list that start with 'JOAO%'
-
7
votes2
answers65
viewsWhat to do when a model has N responsibilities
My system exists a class that is currently a common class for several situations, below some of the other models to exemplify public class Servico { public int Id {get;set;} public string Nome…
-
7
votes2
answers1283
viewsHow to convert ASCII to binary?
I’m trying to implement the conversion of a text to binary, I found one on the internet: static string ASCII_binary(string texto) { string converted = string.Empty; byte[] byteArray =…
-
7
votes2
answers853
viewsHow to get Text from a Listview?
How can I catch the Text of my Label that is inside a ListView without using the FindControl (Item.FindControl("lblCodigoEdit") as Label).Text), or is access directly the value it has in mine…
-
7
votes1
answer280
viewsHow to read data in Json on the server?
I have an Asp.Net MVC project and I’m trying to repurpose an Action that returns Json within the server, but I’m unable to work with Json returns in C#. I’m doing research, but I haven’t found…
-
7
votes1
answer686
viewsCorrect method to write to WEB API?
I did a test using a method this way, test using the Postman is worked, wondered if this way I might have any problem. in the Controller…
-
7
votes2
answers642
viewsError while trying to update table using C#
I created a form to change a table, but my update is not working. cnxCli.sel =/*"set dateformat dmy \n"+ */ "update Cliente" + "set Nome = '" + txtNome.Text +"'," + "Rg = '" + mskRg.Text + "'," +…
-
7
votes2
answers2411
viewsCount how many pixels of a color the image has
I am working on a solution for tattoo studios. I would like to know how it would be possible to determine how many pixels a certain color exists in the image inserted in pictureBox1. In this image,…
-
7
votes2
answers1555
viewsShow zero on the left using the Tostring method
I have roughly the following code implemented in c#: using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Teste { public class Program {…
c#asked 7 years, 6 months ago HenriqueNeves 73 -
7
votes1
answer1438
viewsGenerate header when exporting data to excel
I did an export routine for the excel, using StreamWriter, but it causes me a problem. I can’t get the name of the columns that come in select. To make the header, I had to put it in the hand. This…
-
7
votes1
answer107
viewsCompare Strings by format not by value
I have a shape of a String, for example: xxxx-xxxx-xxx But instead of the x can enter several letters or numbers, example: A216-0450-013 X2LP-1018-589 Y585-0000-047 What I need to do is compare to…
-
7
votes2
answers2252
viewsSelecting a value from a Listview row/column populated by LINQ to SQL
Through the double click event I need to pull a value from a row/column in a Listvview populated by LINQ to SQL. For example, when the user needs to select a value from a row/column of this…
-
7
votes1
answer1464
viewsSimple permutation algorithm
I’m trying to create a simple permutation algorithm where you pass any number for example 123 and it should return the largest number without repeating. I tried something like this more when I pass…
-
7
votes1
answer3139
viewsPython integration with C#
Is there any way to integrate C# and Python 3? I need to create graphical application in a practical and fast way. Currently, I have the scripts in Python working 100%, now what I need is to take…
-
7
votes2
answers222
viewsUpdate model partially with Webapi2
I am starting to develop a REST API using ASP.NET Webapi2. In my controller, I’m using the method PATCH to apply partial changes to a model. I have a method that is this way [HttpPatch]…
-
7
votes1
answer144
viewsShare types between API and client application
I am developing a REST API using ASP.NET Webapi 2 and, as I come from the old SOAP standard, I’m used to type sharing between the API and the client. That is, when referencing my service in the…
-
7
votes1
answer982
viewsUpdating application(C#) in real time with Database (Mysql)
I am creating a server client application, the application would run on several machines using the same database(mysql) on an online server. I would like that once the data of a table were changed,…
-
7
votes2
answers611
viewsSuggestion Migration System and modeling of individuals and legal entities in system with Entity Framework
Well, here’s the thing. I have a database that has the purpose of making a company’s ledger, basically this bank has a table CaixaCorrido with the columns Id, PessoaNome, DataHora, Descricao, Valor,…
-
7
votes1
answer94
viewsUpdate to 2K records <Clients> how to do a single update instead of 2k separately
I have a Customer Model and need to do an update on EnviadoEmailCobranca para 0 I’m doing like this: var clientes = db.Clientes.Where(w => w.Status == 4); foreach (var item in clientes) {…
-
7
votes1
answer457
viewsHow to create a Custom Attribute?
For some time I’ve been trying to understand the concept of custom attribute of C#. I think it kind of looks like the system of decorators from Python. But I’m not getting it very well. I read in a…
-
7
votes4
answers1193
viewsWhich DBMS to use so that it can be installed on the client’s computer to run a C#application?
I am developing a small C# system that will be implemented on client computers in the future, accessing a local database. Initially I was going to use SQL Server, but I would have to install it next…
-
7
votes3
answers1360
viewsFaster way to access properties in a C#list
I have a project that works with a large volume of data, and I need to optimize it to bring results of some calculations in a considerably small time. I know that I have several aspects to take into…
-
7
votes1
answer18750
viewsHow to integrate the application with Whatsapp?
I was wondering if it is possible to integrate an application made in C# with Whatsapp?
-
7
votes1
answer265
viewsHow to make ASP.NET MVC skins
How would make skins in MVC? where the client(user) could choose the skin (would change CSS, html, images, etc)? OBS¹: The Skin would be for all pages and each customer can have only 1 single skin.…
-
7
votes2
answers3695
viewsUsing string interpolation C# 6
With C# 6 and interpolation usage is better than concatenating string with data. As in the example. Instead of: var d = "19"; string.Format("{0} anos", d); looks much better $"{d} anos"; But using…
-
7
votes2
answers753
viewsDaylight saving time with old dates
In my system save all dates on UTC, but in the user view I show in GMT -3. The problem is when I save a date in summer time, because in case it will no longer be made the difference of 3 hours, it…
-
7
votes2
answers674
viewsRemove an N amount of days on a date
How to remove an amount of N days in a date ? namespace TesteData { class Program { static void Main(string[] args) { var dataAtual = DateTime.Now.Date; // dataAtual 13/09/17 var qtdDias = 5; //Como…
-
7
votes1
answer386
viewsWhat is and how does the repetition of the for in C#?
for (int i = 0; i < palavra.Length; i++) What does each word mean? And how each part of that code works?
-
7
votes1
answer3980
viewsIn which cases return the System Exception error.Outofmemoryexception
Which are the most frequent cases that can return this Exception?
-
7
votes1
answer786
viewsFluent Nhibernate - Composite key mapping one to many
I’m having a problem mapping an entity through Fluent Nhibernate. I have a 1-N relation to the two tables in the bank having composite keys. When I try to list my entity User an error comes back,…
-
7
votes1
answer115
viewsWhy is the expression (double.Minvalue == double.Minvalue + 1) true?
The following code C#: public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine(double.MinValue == double.MinValue + 1); Console.WriteLine(int.MinValue…
-
7
votes3
answers414
viewsHow to change the structure of a LINQ query at runtime?
I have the following example of a program that implements the EF (Entity Framework). The structure of the database and the application is defined as follows: Table Pessoa: Primary key field:…
-
7
votes3
answers1496
viewsWhy is it possible to define two or more methods with the same name in the same class in C#?
I’m starting my C# studies with ASP.NET MVC today. I’m still adapting to some things I’m not used to seeing, because I know languages like PHP, Python and Javascript. I realized that in a code that…
-
7
votes1
answer1103
viewsAsp.Net MVC authentication using Formsauthentication
I am implementing authentication in my ASP.NET MVC application. I am using FormsAuthentication for this authentication of each user and for each logged in user 5 Sessions are assigned (Name,…
-
7
votes2
answers74
viewsWhat is the best type to store area, volume, perimeter?
Decimal, Numeric or Float. What is the best option for storing area or volume? I would use Decimal, but I would like to see the opinion of others as well. I guess not, but the right guy or the next…