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
-
2
votes1
answer128
viewsError using Code First From Database
I’m trying to use the Entity Framework with a Sqlserver database that I created outside of Visual Studio. The problem is that when I add the ADO.NET Entity data Model to the project to do the…
-
2
votes2
answers95
viewsMysql parameter automation does not work
I’m trying to create a way to automate the business of adding parameters in the query to prevent sql inject, but it doesn’t work! This is my code: public static MySqlCommand…
-
2
votes1
answer1122
viewsBrowse Arraylist of object objects and compare c#
I was wondering how I can reuse the object I put into an array list because I can’t compare it to anything, and how I compare an object inside it to another, in this college program the goal was for…
-
2
votes0
answers269
viewsHow to read an excel and insert the data into a table?
I wanted to send data from a file Excel for a table on Sql. I tried using the bulkcopy.ColumnMappings.Add but you’re making a mistake. System.Invalidoperationexception The Given Columnname does not…
-
2
votes2
answers111
viewsTextboxfor with white spaces
I have a Textboxfor that lists the record of a table field. When displaying in the view, the textbox throws blank spaces after displaying the record content. I realized that these spaces are to…
-
2
votes1
answer624
viewsButton on a View with MVC/Web API
When we put a button in a View, how do we fire a click of it? I have this button: @model IEnumerable<CarregaDados.Models.Cliente> @{ ViewBag.Title = "Index"; } <h2>Index</h2>…
-
2
votes1
answer435
viewsDemonstrate calculator in Stack
I have a problem here and I need a help, I have to do a job for college, and a calculator, so far so good I’ve even made the calculator, only the problem and the next, I need to demonstrate the…
c#asked 6 years, 11 months ago Junior Guerreiro 617 -
2
votes1
answer1077
viewsCalling functions from a controller in the _Layout.cshtml view of ASP.NET MVC5
I have a menu being loaded into a controller Action. I’ve already set the view for this action in _Viewstart to be the default for my project. But this view isn’t pulling any comtroller information.…
-
2
votes1
answer822
viewsHow to Print an Array in Windows Forms of Visual Studio?
How can I print an array in windows Forms? I tried by listbox using this code: public void Mostrar_Grafo(int Qtdlinha,int Qtdcoluna, string[,] MAdjacencia) { ListBox listbox1 = new ListBox();…
c#asked 6 years, 11 months ago Kevin De Bortoli 67 -
2
votes2
answers318
viewsHow to load values in the combobox by the form load event C#
I’m trying through this code: private void frmAdicionarProdutos_Load(object sender, EventArgs e) { string serverName = "localhost"; string port = "5432"; string userName = "postgres"; string…
-
2
votes1
answer468
viewsTransactionscope - Rollback problem
I need the Transactionscope do Rollback case any of these foreach error. I added a Exception manually between 2º and 3º foreach to test whether the rollback, but the information saved in the bank of…
-
2
votes4
answers3505
viewsHow to generate random characters or string?
How to specify the number of times a character can repeat? Ex: I have ABC, where C should repeat 4 times in a new string 6-character: ( AB CC CC ) or (AC CB CC) or ( AC CC CB ) To can only enter…
-
2
votes2
answers812
viewsbut this Dictionary requires a model item of type 'System.Collections.Generic.Ienumerable`1[Webapplication4.Models.modelExemplo]
I can not carry out enumerate, I switched to another reception of information in the View but I do not know how to correct, I checked other forms in Stackoverflow but I did not understand. Model:…
-
2
votes1
answer368
viewsHow to pass data from Datagridview to Reportviewer
I need to pass data from DataGridView to the ReportViewer to make impression, but as I am still novice in c# I am not able to pass the datatable to the form of ReportViewer, if anyone can explain me…
c#asked 6 years, 11 months ago Junior Guerreiro 617 -
2
votes1
answer669
viewsSave to txt file and recover in a combobox
This is what I need to do: Registering a customer on the form. Save the nome of clients that are registered in a txt file on the computer, example: John Marcos Willian Load these names into a…
-
2
votes2
answers1332
viewsRelationship one for many and many for an Entity Framework
I am developing these classes of this diagram, but I am in doubt how to declare relationships [One for many, and many for one] This is the diagram: for example Product has a Category, and a Category…
-
2
votes1
answer680
viewsShow specific error in ASP.NET MVC
I created a site that works normally, however, when uploading it to the hosting server, it shows an error: Server Error in Application '/'. Since the error is too generic, he says to include the…
-
2
votes1
answer233
viewsQuery a specific node of an XML file in c#
I have a login system in C# and a following XML file: <?xml version="1.0"?> <Usuarios> <Usuario> <User_ID>001</User_ID> <Password>010309</Password>…
-
2
votes3
answers636
viewsLoad grid information in textbox in a form that is already open c# windows form
Hello I’m trying to do something that seems simple but I’m not getting, I want to click on a button add the data of a grid go to another form that is already open. the problem is that I am only able…
-
2
votes0
answers72
viewsWebservice VB.NET - Return list(of ) without structure TAG
I have a need to generate an XML code returned through a Webmethod() in the following format. Notice the content within the TAG <user_list>, which must have a list(of) or an unassembled…
-
2
votes1
answer1291
viewsInitializecomponent does not exist in the current context
I have this code, where I have the error [XamlCompilation(XamlCompilationOptions.Compile)] public partial class AprovarPopup : PopupPage { public AprovarPopup() { InitializeComponent(); } protected…
-
2
votes1
answer432
viewsPlay value from a grid that is in form to another grid in another form C# windows form
Hello I’m here with another situation requesting help because there is not yet found in the surveys. I have a form that I put a Gridview, the form has button to open another query form and when I…
-
2
votes1
answer358
viewssum column lambda expression
I need to return the sum of the column value_business, I have the following expression dynamic contato = (from a in context.Negocio join cli in context.Pessoa on a.id_cliente equals cli.id_pessoa…
-
2
votes1
answer107
viewsError inserting data from an excel file into sql
I have a problem when I insert data from excel file into the database because a field that I am entering says it is not of the type time and does not allow inserting , but in the excel file the text…
-
2
votes2
answers200
viewsIs there any way to implement an interface in a class of a DLL that I can only read?
I am using a DLL that has several classes. I would like to dynamically implement interfaces for these classes, so that I can perform unit tests by making a mock of the same. Is there any way to do…
-
2
votes1
answer405
viewsBring a newly added ID to put in a textbox c# windows form
I request a help to do the following, I do an Insert via Procedure after saving I want to fill the textbox with the id created so I can use it to associate to my item I just need the order code to…
-
2
votes1
answer70
viewsDoubt about which Inheritance to use in the Entity Framework
I only had the opportunity to use the EF basically 1x. Therefore, I am with many doubts, even consulting a lot google. I have a client application that will take various data from the logged user’s…
-
2
votes1
answer196
viewsDoubt about Visual Inheritance between Windows in WPF
I’m new to WPF and I’d like to clear up a question that I think most people have, but can’t quite clear up, which is the visual heritage of windows. Imagine that all my sign-up screens should look…
-
2
votes1
answer299
viewsError: Multiple controller types Were found that match the URL
When requesting a service by my App, gives me this error: Multiple controller types Were found that match the URL. This can if happen attribute Routes on Multiple controllers match the requested…
-
2
votes1
answer148
viewsPicturebox Dinâmico
I have a table called "Subordinate" where users are registered with their respective photos. I have a form and need to display the photos of all registered users. For this I have the following…
c#asked 6 years, 11 months ago Pedro Henrique Rocha 65 -
2
votes1
answer187
viewsHow to separate a string in Unity c#
I wanted to know how to separate a string in Unity C#, I ended up looking at some similar questions for C# punch not in Unity, I often found this example string[] linha = reader.ReadLine().Split(new…
-
2
votes1
answer226
viewsDoubt - Winforms on the subject on the second screen
Form1 created panel with black background and label property: Autosize = False Dock = Fill Font size(Size) = 20 And 2 buttons to forward or back letters Form2 only has a black form and a property…
-
2
votes1
answer706
viewsImplicit conversion of the nvarchar data type into varbinary(max) is not allowed. Use the CONVERT function to perform this query
Follows code: byte[] image1 = ConvertTo.Bytes(Request.Files[0]); byte[] image2 = null; ctx .Users .Where(x => x.Id == 1) .Update(x => new User() { ImageByte1 = image1, ImageByte2 = image2 });…
-
2
votes1
answer106
viewsWhat is the purpose of the "[Bind("ID,Title,Releasedate,Genre,Price")]" feature in a method?
I am creating a project in ASP.NET Core MVC for learning purposes. In a certain part of the Microsoft guide when the technique of scaffold to generate the controller and the views corresponding to…
-
2
votes1
answer891
viewsCan I edit Identity’s Aspnetusers table?
Galera I have a project that has a table of USUARIOS. And now we’re migrating to AspNet.Identity which already has a table but called AspNetUser and with your own fields. And my table USUARIOS have…
-
2
votes1
answer382
viewsError c# and Mysql: Authentication with old password no longer supported, use 4.1 style passwords
Context: We have an application built a few years ago in ASP 6 that accesses a Mysql database, there on Localweb. To make the connection, the application uses the Mysql ODBC 5.1 driver. and works…
-
2
votes3
answers679
viewsEntity Relationship Framework 1:N
Hello. I have the following classes... Sales class: [Table("venda")] public class Vendas { public Vendas() { ItensVendas= new List<ItensVendas>(); } [Key] public int Id { get; set; } public…
-
2
votes0
answers249
viewsError while connecting Mysql using .NET. How to resolve?
Exception when connecting to the bank: Ispasswordexpired: 'Conn.Ispasswordexpired' threw an Exception of type 'System.Nullreferenceexception' Serverthread: 'Conn.Serverthread' threw an Exception of…
-
2
votes2
answers1855
viewsStopwatch construction
I’m building a stopwatch using WPF. When I performed some tests, I realized that the timer on WPF is delayed in relation to my timer iPhone. The difference starts to appear from 8 seconds after the…
-
2
votes2
answers4027
viewsProblem communicating with eSocial webservice
I have the following problem when communicating with eSocial webservice, I am using C# so I added the reference of the webservice in my project and now I need to send an XML, and what I thought was:…
-
2
votes1
answer87
viewsDynamically remove components in C#
Good evening, I’m trying to solve a problem I came across by dynamically trying to remove the picturebox I created: namespace WindowsFormsApplication8 { public partial class Form1 : Form { int count…
-
2
votes1
answer183
viewsPaging a Datagridview
Good afternoon to you... I have a datagridview that loads several lines, I’ve been searching on the net how I can paginate this datagridview, but I could not perform such procedure, because I have…
c#asked 6 years, 10 months ago Junior Guerreiro 617 -
2
votes1
answer1660
viewsC# AES encryption with MD5
I’m doing a college paper where I need to encrypt a string with AES and Md5. When I do the encryption, returns the normal result (I think), but when I go decrypt, returns the following error:…
-
2
votes1
answer142
viewsRatio 1:N check date, difference 6 month
I am developing a SQL Server Database, which lists two tables: Where a process has N movements, I need to return the following data: all Process that have the column Irrecuperavel(int) = 1 and that…
-
2
votes1
answer346
viewsLoad list from txt in c#
I have the following problem, I get the data from a txt that I need to return in the form of List<List<string>>, but I can only catch from the txt one string [] linha, so I was adding…
-
2
votes1
answer820
viewsReturn int in a select using Dapper.
I need to return the idCity. If it is not found in one table, it is obligatory in the other. The return is nil. My Query public const string sql = @"DECLARE @retorno AS INT = 0; SELECT @retorno = id…
-
2
votes1
answer136
viewsIs it possible to omit the numbers of the "String.Format" formatting arguments in C#?
I was seeing that in Python is possible format a string without numbering the arguments. Example: #mensagem = "Meu nome é {0} e minha idade é {1}"; mensagem = "Meu nome é {} e minha idade é…
-
2
votes1
answer84
viewsRead XML file, server returning error
I wrote a code to read RSS feed that works well. If you access this URL will see that returns an XML in the browser, but when running in my code generates an internal error on the server and do not…
-
2
votes1
answer454
viewsHow to Include and Reference . JS in my project?
Well here’s the thing, I have a file. JS in my project. I’m calling him at HEAD LIKE THAT: <script type ="text/javascript" src="~/JS/validacao.js"></script> within this validation.JS has…
-
2
votes1
answer158
viewsAdd photos and gallery to an ASP MVC product
I’m starting in Asp.net using mvc 5, I’ve taken some basic courses, and now I want to make a simple little complex virtual store. but I am in a crucial doubt in the product table, it will have a…