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
answer97
viewsTask List<T> showing Xamarin error
I am creating a Task List<> but the same shows error in 'Tmodel' Error shown: "Tmodel" type or namespace name cannot be found (using a directive or Assembly reference?) public async…
-
2
votes1
answer197
viewsPOST model reaching null in controller
I’m having a complicated problem with my code that I can’t seem to solve. Initially, I have a function SubmitUsuarioRegistro of Javascript that carries out the post of the user’s profile, forwarding…
-
2
votes1
answer161
viewsDownload Bank Image with ASP.NET MVC5
I am saving images in the database in varbinary format. byte[] arrayImagem = null; using (MemoryStream memoryStream = new MemoryStream()) { novaSolicitacao.Anexos.InputStream.CopyTo(memoryStream);…
-
2
votes1
answer31
viewsI need to create a Compound dataset using HDF in C#
My application contains a list of Basicvariables and within each of the BV’s, I have a list of objects of class OPC_UA, which have 3 attributes, a datetime (which I will convert to a timestamp), a…
-
2
votes1
answer77
viewsHow do I verify that all data on my list exists in the database?
I need to take the files that are in a list and compare with the files that are in a table in the database, and know if the amount of files that is in my list is the same amount as the table. using…
-
2
votes0
answers47
viewsHow to use class A functions in class B and vice versa?
Hello, I’m trying to make a game but I found a problem where I can’t solve, maybe the answer is really stupid, but since I’m kind of busy, I can’t find it at all. This is my first class or Script,…
-
2
votes0
answers54
viewsWPF and MVVM Standard, doubts
I’m studying C# and I’m having to develop a WPF application with the MVVM standard. One question I have about this pattern is in relation to events, I have read in some places that it is not…
-
2
votes1
answer73
viewsConsuming a Web Service Asp . Net Xamarin application
I want to make a request to a Web Service developed in Asp . Net passing two parameters to my server. The controller in the web Service this asism: public HttpResponseMessage Get(string id1, string…
-
2
votes2
answers141
viewsHow to create a class and pass an attribute value in the class constructor in C#
Hello, I’m making an integration with the Tray Comerce API and thought to generate a generic class with the response of lists. In all listings, the API implements the following return class: public…
-
2
votes1
answer45
viewsWCF as Windows Service
I’m creating a WCF, and it’s like this: ServiceHost host = new WebServiceHost(typeof(Server)); WebHttpBinding binding = new WebHttpBinding(); binding.MaxReceivedMessageSize = 999999999;…
-
2
votes1
answer2142
viewsRead a value inside a complex JSON in C#
Good morning folks! I’m new to C# and I’m having a hard time picking up a value within a complex Json. This is Json: { "id": "58e50b82-50b1-4f29-a2e8-a9a544013255", "timestamp":…
-
2
votes1
answer277
viewsWCF error starting as Windows service
I am trying to start a WCF as Windows service, but it returns me the following error: HTTP could not register the URL http://+:80/. Your process has no access rights to this namespace (see website…
-
2
votes1
answer388
viewsTreeview with Nodes & Childs via SQL database
I wonder how can I popular a TreeView with Nodes and Childs via an SQL connection. The connection is already done this is the code I have for now, but it does not work because it adds only a Node…
-
2
votes2
answers117
viewsHow to turn an array of bytes into an image in WPF?
I have an array of bytes like this: private byte[] m_Frame I need to turn him into an image, only how I’m in one WPF it is not possible to simply play a bitmap within a PictureBox because that…
-
2
votes1
answer630
viewsHow to check if there is a specific data in a multidimensional array C#
Work in a school that makes the students frequency control by digital, each time a student "hits" the finger is added to a code to a txt, if the student hit 1 time is recorded input if he hit 2…
-
2
votes2
answers172
viewsScroll Element of the WPF C#Datagrid class
I have a function that creates a grid, But I don’t know how to get that value, the function is down here: using System.Windows.Controls; public override FrameworkElement criar() { if (formulario ==…
-
2
votes1
answer1146
viewsError While Creating Migration
I am creating a user register in C#, but when including the Domain layer and I will create the Migration is happening the error below. I haven’t been able to identify what happens. "No suitable…
-
2
votes1
answer65
viewsHow to get a value using interpolation?
I am trying to recover a class value using interpolation. Using Console.WriteLine($"Meu Nome é, {pessoa.Nome}");, I get the value of the form I want, but in my case the string will come from a…
-
2
votes1
answer278
views.NET Core and Mono: application development for Linux
Currently I have needed to develop applications (desktop) for Linux, and one of the requirements is that it would have to be using C#. And researching/testing, I got two options: .NET Core or Mono.…
-
2
votes2
answers3129
viewsHow to assemble a Restrequest with x-www-form-urlencoded in Restsharp C#
I know how to requisition using Restsharp when the content-type = application/json, now I need to make a request application/x-www-form-urlencoded but I can’t find the right way to do it, follow the…
-
2
votes1
answer25
viewsHow to change the view of toggle buttons based on a Binding in WPF Datagrid
Hello, I am new with XAML/WPF and I have the following problem. I have a DataGrid which receives as Itemssource a ObservableCollection<DataEstoque>() thus public class DataEstoque { public…
-
2
votes3
answers80
viewsHow to deal specifically with a Keynotfoundexception?
I have a doubt, I tried to find some content on Google but I did not find. I have a block try catch as follows: try { //código string idFormaPgto =…
c#asked 6 years, 2 months ago Leonardo Bonetti 5,313 -
2
votes1
answer51
viewsHow to ensure that all information was recorded at the bank?
I’ve been realizing that I’m having trouble recording information in the bank because: -I’m running a block of a method that records data in the database: //codigo aqui…
-
2
votes2
answers202
viewsModel error on Razor page
I have this cshtml @model IEnumerable<TreinamentoCrud.Models.Cidade> @{ ViewBag.Title = "Index"; } <h2>Index</h2> <p> @Html.ActionLink("Create New", "Create") </p>…
-
2
votes1
answer107
viewsI’m not getting a list of an API
This URL works on Postman: http://localhost:56137/api/Getcidade. I need now in another MVC project to bring the list of cities. When I do this I catch this mistake: The template item inserted in the…
-
2
votes0
answers39
viewsThreading Problems in Windows Form
I’m trying to implement Threads in my algorithm, however when adding and running my software the Windows Form of it hangs and does not perform any action, can you see anything wrong in the code…
-
2
votes1
answer65
viewsIs Streamreader reading a line that doesn’t exist?
I want to read a CSV file and save it in a table, but for some reason it still gives the following error: System.Nullreferenceexception: 'Object Reference not set to an instance of an Object.' line…
-
2
votes1
answer250
viewsError adding data to database
I’m having trouble inserting the information with parameters: private static void InsereNovoMenuParaOUsuario(int idAcao, DTO.ModulosProgramaAcoes acao) { using (var conn = Conexao.ConectaDb()) { var…
c#asked 6 years, 1 month ago André Andriotti 21 -
2
votes1
answer1277
viewsSSL/TLS error when trying to perform Cielo API transaction
All week long I have had problems in calling their API, I get only the following error: The underlying connection was closed unexpected error in a send My code called in Restsharp is: public…
c#asked 6 years, 1 month ago Leonardo Bonetti 5,313 -
2
votes2
answers122
viewsDoes it make sense to use an api to access another api? (bematec one in this case)
I was asked to make an API here where I work to integrate some systems with nfce. For that, they hired the one api. More information can be found here:…
-
2
votes2
answers271
viewsDapper requires writing SQL code, why?
I’m looking at the following link that uses Dapper: Getting Started With Postgresql Using Dapper In . NET Core and my question is, when I do Java I don’t need to write SQL code as this example here:…
-
2
votes0
answers27
viewsSpatial data
What are the . net classes for working with geographic data (latitude, longitude, etc)? During a search I found the namespace System.Spatial but I saw in a forum someone advising against its use for…
-
2
votes1
answer268
viewsC# Webbrowser How can I get innerHTML from a span within a div
HI GUYS. I need to get c# the innerHTML of the first SPAN element that has a value with numbers that is inside a div and I I’ve even written a code that’s on the right track, I think. So far this is…
-
2
votes1
answer52
viewsI’m trying to make a rollback of my Querys only to give me a mistake in Executescalar
The code works perfectly without the btw rollback. SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString); con.Open(); SqlTransaction tran =…
-
2
votes0
answers487
viewsRender Image with Rotary Pdf (Asp.net Mvc)
I have an Action responsible for generating the pdf using Rotary... The action code is as follows:: public ActionResult PDFPadrao() { string header = Server.MapPath("~/Views/Relatorio/Header.html");…
-
2
votes2
answers45
viewsGroup select and return exact amount
Guys I’m using Entity and I have a query that returns some 2000 lines. After doing this: base.Get(queryParameters) .GroupBy(x => new { x.Id }) Until then it is normal,I work with pagedlist, where…
-
2
votes2
answers4833
viewsError: Invalid thread operation
I’m trying to open the Webcam, but every time I try to execute the method iniciarwebcam() it returns me the error: There was an exception of type "System.Invalidoperationexception" in…
c#asked 6 years, 1 month ago Daniel Souto 35 -
2
votes1
answer105
viewsInclude in Entity Framework from an Enumerable
I have the following entities: public class Rota { public Rota() { CidadesRotas = new List<CidadesRota>(); } public int RotaId { get; set; } public string Descricao { get; set; } public string…
-
2
votes1
answer214
viewsResize image in c#
I would like to know how to resize images in c#. I will receive images in both JPG, JPEG, GIF and PNG. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;…
c#asked 6 years, 1 month ago Marcelo Batista 1,617 -
2
votes1
answer133
viewsPassing a Connection string dynamically
Well my problem would be trying to pass a connection string from a txt. file which is also used to bring the items from my Combobox, the goal and bring a different database depending on the item…
-
2
votes1
answer455
viewsReturn Result of an IF executed by Command Prompt(CMD) in C#
Hello, I’m trying to get a return from an IF line from Command Prompt (CMD) with Visual Studio 2015 in C#, but I’m not getting it. The following Code, runs the CMD, inserts the directory path that…
-
2
votes1
answer156
viewsJsonconvert.Deserializeobject returns null
Segue json: [ { "id":"BKA-EU8IED8ZD21Q", "agencyNumber":"1", "accountNumber":"1", "holder":{ "thirdParty":false, "taxDocument":{ "number":"783.121.360-02", "type":"CPF" }, "fullname":"Leandro da…
-
2
votes1
answer45
viewsDatagridview displaying incomplete id
The grid displays only the first character of the "ID" For example: if the ID is 16 it displays 1; If it’s 20 displays 2; However from 1 to 9 displays correctly... Code that selects the data...…
-
2
votes1
answer40
viewsDoubt generating entity from Cs file code in edmx C#
In the version of ".Net Framework 4" I have a project that when using . edmx did the automatic generation of Edmschema where in my project I did so: 1 - ADO - (Project Class Library) 2 - Archive .…
-
2
votes0
answers156
viewsECDH between C# and javascript
I’m creating a web API and need to implement ECDH for end-to-end encryption. On the server side I have a C# application and on the client side a javascript application. I can switch keys, generate…
-
2
votes2
answers377
viewsTimout when searching between 2 date intervals
I have a query where I make a query between 2 date ranges. On those dates, I apply the DbFunctions.TruncateTime to filter searches only by dates, ignoring the time. Obs: are fields Datetime .Where(p…
-
2
votes1
answer199
viewsHow to get all 'Yamldotnet' values in 'File.yml'?
I’m working on a.yml file and I want to get all the values it contains in that file. I’m using the reference Yamldotnet.Serialization. What I want to do is take a certain value and display the…
-
2
votes1
answer200
viewsHow to split the screen with 2 Open Forms within an MDI
Good morning to you all. I have a question about forms. In my application, I can open 2 forms with grids where they present factory information. Those Grids are updated every 30 seconds, and are…
-
2
votes1
answer43
viewsHow to use a literal tuple as property of a class in C#
Hello, I’m working with C# and I read about literal tuples. With that, I’m creating the class below: public class Foo { public (int bar, string bin)? barBin { get; set; } } In theory, in order for…
c#asked 6 years, 1 month ago LeandroLuk 4,989 -
2
votes1
answer486
viewsConvert Byte to Normal Text c#
I need to read a byte (Buffer), and convert it to Common Text, that is, I need to convert to letters and/or numbers of the ASCII table. I am using this function to convert to ASCII Note: when I put:…
c#asked 6 years, 1 month ago Leandro Kojima 429