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
-
1
votes1
answer2998
viewsError deserializing a Json I receive from the server
Cannot deserialize the Current JSON array (e.g. [1,2,3]) into type 'Gnaritas.Coletor.Templates.Fieldfieldcollection' because the type requires a JSON Object (e.g. {"name":"value"}) to deserialize…
-
1
votes1
answer131
viewsExecutesqlcommand - Update byte - Error
Follows code: var bytes = ConvertTo.Bytes(file); int num = ctx.Database.ExecuteSqlCommand( $"UPDATE dbo.Table" + $"SET Video = '{bytes}' " + $"WHERE id = {Id} "); Follow code to convert: public…
-
1
votes1
answer458
viewsPartialview relationships Asp.net mvc 5
I’m having trouble creating the logic of registering models that has relationship between them. One exists only the reference, but in the other the reference is of type List<>. I created a…
-
1
votes1
answer6168
viewsError in Webservices Json C# "Unexpected Character encountered while Parsing value: <. Path '', line 0, position 0."
Hello, I’m getting an error in the execution of my code, in another application the same code works, I’ve changed the using, but it doesn’t work. public String CriaPeca(String token, String ip,…
-
1
votes1
answer365
viewsFill Linechart(Line chart) wpf with data from a sql server query
Hello, I’m having trouble finding a solution to fill my linechart with data from a query, my connection class is complete and working, but I don’t know how to apply on Chart, I don’t know how to…
-
1
votes1
answer275
viewsPass complex object vs simplest object per parameter
In the method Log there is the type parameter HttpClient. The function only uses the parameter to access the property BaseAddress, which is a Uri. private void Log(string verb, HttpClient…
-
1
votes0
answers94
viewsActionresult search result does not return all results for View Pagedlist
I noticed that on my application before adding to View the Paged List he received all items returned from Actionresult responsible for the research, then from the implementation of the Paged List I…
-
1
votes0
answers81
viewsProblem when climbing Web Api in Asp.net core using Entity framework with postgresql
Hello! So, I already checked my classes in the bank, I successfully mirrored and started to assemble the functionalities of my webservice. With that, I came across the following mistake:…
-
1
votes2
answers220
viewsWhat is the best way to treat Exceptions and Log in Webapi (C#)?
Setting: Webapis in . NET 4.x Goal: Improve Logging (info, error, debug, Warning) and Exception Handling, for example, log in exceptions, which Log frameworks do you use? Where do you store Logs? I…
-
1
votes1
answer94
viewsMongodb in Azure
A while ago I had an unpleasant surprise on my Azure invoice on account of a Mongodb database that I owned for access to an application. I created, for example, the documents: Client Product Request…
-
1
votes1
answer544
viewsBasic Authentication in Webservice Rest C#
good afternoon!! I’m implementing a Webservice Rest but I’m not able to call the Basicauthentication method another class. [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,…
-
1
votes1
answer160
viewsGeneric CRUD in Entity Framework with unspecified entity
I’m trying to make a generic CRUD for my project. However as I used Databasefirst I do not see how to have a generic class of Entity that can be inherited. Because it doesn’t make any sense,…
-
1
votes2
answers537
viewsShow error message when Modelstate is not valid
When I submit the form it recognizes that the ModelState.Valid is invalid but when it returns to View() does not show the error messages I put in Model. My Controller : [HttpPost]…
-
1
votes3
answers5808
viewsProblem running Visual studio debugger
I have a problem in my project, I use ASP.NET MVC 5 and for a while I get this message whenever I run my project, the problem is not the visual studio installed on the machine(as in that solution)…
-
1
votes2
answers1003
viewsReport generated with reportview, directly in pdf
I have a form, and in this form, I have a button print out which opens a reportviwer report made with a dataset. What I need to do with this report is automate it, instead of me clicking the print…
c#asked 7 years ago Junior Guerreiro 617 -
1
votes1
answer686
viewsHow to draw words from an array without repeating them?
I am doing a college project where I need to simulate the lottery, so I have an array with the name of 20 teams and I need to draw 10 teams but without repeating any and present these teams in a…
-
1
votes2
answers275
viewsHow to access the database directly from my model class in an ASP.NET Core project?
In ASP.NET Core Mvc I can access Dbcontext in the Controller through the property _context represented by my class MvcNotaContext see: private readonly MvcNotaContext _context; This way I can…
-
1
votes1
answer341
viewsAspnet.Identity Creating user with Role
It’s the first time I’m working with Entity and Identity and I’m confused about how to persist my user. Basically I have a table User, with several relationships with the bank and Id int) I have the…
-
1
votes1
answer81
viewsForeach in an Actionresult of details
I have an entity Registering who owns a Professor, the Professor has a list of Registering. How can I create a foreach in View details of Registering to list the name of Professor which belongs to…
-
1
votes1
answer67
viewsCommon events?
Good evening, I would like to associate a common event for all label_DragOver and label_DragDrop... such a thing would be possible? string _currLabel = string.Empty; private void Form1_Load(object…
-
1
votes1
answer193
viewsDeserialize Image in ASP.NET Webform
Well I am with a doubt about the deserialization of an image in webforms, I am working with Oracle database that is my context and using the Entity framework for image I am using BLOB, I was able to…
-
1
votes0
answers487
viewsASP.NET MVC 5: Link two models in the view
I have the following scenario: Agendaviewmodel.Cs public class AgendaViewModel { [HiddenInput(DisplayValue = false)] public int Id { get; set; } [HiddenInput(DisplayValue = false)] public int…
-
1
votes2
answers77
viewsdistinct use in a dropdownlist
I’m trying to get equal names off my dropdownlist, but they’re different id’s. I wanted where I would have to implant the code if it would be in the view, or in the controller somewhere else. Data…
-
1
votes1
answer401
viewsReport Viewer Schema 2016
When adding a parameter to a ReportViewer is happening from the version of schema move to 2016, which brings me to the following error when trying to render the report Message: Test method…
-
1
votes1
answer141
viewsdoubt expression Innuendo, clause IN
I have the following expression retorno = (from ven in context.VendaModel select new { ven.barras, ven.data, ven.valor }).ToList(); I need to search only what you have on a list that will be passed…
-
1
votes1
answer173
viewsHow to assign a List<> to a Datatable correctly windowns Form?
I’m trying to list the payment methods of the table dbo.FormaPgto in a Combobox but you’re making that mistake. Follows code. Class: public List<Formas_Pagamento> ListarFormaPgto(string campos…
c#asked 7 years ago Igor Carreiro 1,917 -
1
votes1
answer165
viewsCompress Access Database with C#
I have a method to compress my base Access, but when I run the program I have the following error: Error: A catch Exception brings this message: {"Retrieving the COM class Factory for Component with…
-
1
votes1
answer1350
viewsConvert file to Array of bytes
I’m trying to convert a received file into FileUpload (ASP.NET tool) for a array of bytes and then the array for a string. But when trying to use the Encoding Visual Studio accuses an error saying…
-
1
votes1
answer149
viewsUnrecognized class C# WINDOWS FORMS
I have a new problem in the same method, the place in bold and italics accuses an unrecognized class problem, some hint how to solve? Code to follow: public static void CompactarMdb(string…
c#asked 7 years ago user93952 -
1
votes2
answers113
viewsError translating structure code from C++ to C#
I’m trying to read a string of a process, I found this structure on the Internet: struct name { wchar_t nome[32]; }; I did it that way: struct name { public char[] nome = new char[32]; } And is…
-
1
votes1
answer122
viewsHow to instantiate a part of a class with Entityframework working with CRUD only on these data
I am creating a solution for the web in the Singlepageaplication (SPA) type made with Aspnetcore and I use the Entity Framework to make my CRUD in the SQL Server database. I am sure that the Entity…
-
1
votes1
answer188
viewsData Flow Task: Processes but does not write to the Database
I am using SQL Server Integration Services (SSIS) with SQL Server Data Tools (graphical component for Visual Studio 2015). Within my processing package (SSIS) I have streams that, depending on the…
-
1
votes1
answer44
viewsSend more than one string to serial
I’m creating a string through two values, one read through a slider and the other through a check box. Put the two together in a string called a and send at the same time in the serial. Follows the…
-
1
votes3
answers886
viewsLoad Datagridview with Mysql
I have the following problem to display the data in a pulling gridView of Mysql database public string CarregarAluno() { string retorno = ""; string sql = "select * from alunos"; MySqlConnection…
-
1
votes1
answer130
viewsHow to get value from a field in SQL using C#?
The idea is that I insert data referring to the same person within SQL, but in different Entities, contextualizing: I have the table Pessoa: create table Pessoa( ID_Pessoa int primary key identity…
-
1
votes2
answers126
viewsHow to insert a Where into a Linux query
I have the following query: var result = (from line in db.ApadrinhamentoListas group new { line } by new { line.datahora, line.valor_doacao } into grp select new { DataHora = grp.Key.datahora, Valor…
-
1
votes1
answer239
viewsHow to update listbox from another Form?
Follows code: Class: public class Louvor { public int Value { get; set; } public string Text { get; set; } } Form2: Form1 form = new Form1(); var data = new List<Louvor>(); var files =…
-
1
votes1
answer18
viewsHow to delete the line it automatically generates in a gridView windowns form
I have a gridView that once it is populated with data, it always generates an extra line. How do I remove ? Obs. Grid columns are generated dynamically. if (objPed.ConsultarPedido(Metodos.empresa,…
-
1
votes1
answer41
viewsFind specific data within a List
I have a List<Class> originated from a class. Class properties are: datetime DataCotacao double ValorCotação double FatorDiario Follow the data registered for example: Data FatorDiario…
c#asked 6 years, 11 months ago cabarbosa78 21 -
1
votes2
answers1243
viewsReceive images in ASP.Net Core and save to Entity Framework
Good afternoon, Can anyone tell me how to get an image on ASP.Net Core ? I have the html page that tries to send to the server: <form method="post" enctype="multipart/form-data"…
-
1
votes1
answer87
viewsRule Rewrite Changing script directories
I have the following problem, when using the Rule below my default directory is changed and mine js scripts and files css stop working. <rule name="Produtos Detalhe"> <match…
-
1
votes1
answer236
viewsProblems with a Dependency Injection Container - Simple Injector
I am mounting my ID container using Simple Injector, but it is giving a compilation error (Underlined in red) in config. from the Ireadonlyrepository interface with the Clientedapperrepository…
-
1
votes2
answers3016
viewsDoubt with Webrequest get method passing token
I’m trying to read the data of an order, where I send the information via get, Error: Unable to send content with this verb type. public string ConsultaPedido(string urlpedido, string NumeroPedido)…
-
1
votes1
answer52
viewsDoubt on how to Map an Interface with a Class - Simpleinjector
I’m having trouble mapping the Interface IClienteRepository with class ClienteRepository. When compiling the application, this error appears: "Exception {"To be Able to use the Lifestyle.Scoped…
-
1
votes1
answer1370
viewsHow to read a JSON file using C#?
I have my code that reads an external API and returns me the information, I would like to read this information or add them in a class: I’m using Newtonsoft.Json; This the Json: { "success": true,…
-
1
votes0
answers262
viewsReturn a Partialview in ASP.NET MVC
On returning a Partialview my action can both have as a return Actionresult as a Partialviewresult. public PartialViewResult Franquias() { return PartialView("_Franquias"); } Or public ActionResult…
-
1
votes2
answers384
viewsApi that receives an Item Array
I have the following situation, I need to create an API that will receive the content below: { "numeroCarrinho": 122865, "itens": { "PA00058": 1, "MA00068": 1, "PA00004": 1 }, "cep": "41706670",…
-
1
votes1
answer162
viewsHow to read class data
I have an api that when receiving the data fills a class, I want to do a while in this class tb_dados_api and tb_carrinho, take the data to record in the database, how could I do that? Thanks Here I…
-
1
votes1
answer597
viewsDesign Standards: Singleton Design Standards
I know that the Singleton guarantees me a single instance of a given object. I understood this. What creates doubt would be its use in practice like this. Let’s assume the code below, using…
-
1
votes0
answers169
viewsReturn list in an array - Webapi C#
Good guys. I need to return a list of courses linked to a particular student, this list will be consumed through the get of a Webapi. I have the classes "student", "course" and "cursoAluno" (tables…