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
-
0
votes1
answer43
viewsHow to reuse an Enum on other screens containing some different properties
I’m working with a screen "Financial" and another screen "Financial Report". For the Financial screen, I created an Enum with the options "Accounts Payable and Receivables". public enum…
-
0
votes0
answers67
viewsHow to implement in C++ and use in C# in VS?
EDIT: I want to implement in C++ (no limitations, using intrinsics, inlines, optimizing and everything else normally), choose what in what has been implemented is visible in . NET (C# at least) and…
-
0
votes1
answer44
viewsRefactor code using LINQ in C#
I need to refactor this method in C# and replace these 3 foreach with something smaller using LINQ: public List<Ponto> Filtrar(IQueryable<Ponto> pontosFiltrados, List<Usuario>…
-
0
votes0
answers26
viewsProblems with C# and UTF-16
the scenario is this... I am exchanging data with a websocket, however, one of the messages I send no reply. The message contains the following " X02 x00" but when compiling turns to " u0002 0". It…
c#asked 3 years, 11 months ago Sloan Moura 12 -
0
votes0
answers12
viewsNameandidprovider does not find reference in the class context - ASP.NET Core MVC
I need to do a custom implementation for the input field, so I created the following class: [HtmlTargetElement("input", Attributes = "tm-for", TagStructure = TagStructure.WithoutEndTag)] public…
-
0
votes1
answer75
viewsProblem using Identity in API ASP . NET Core
Good afternoon, I’m trying to use Identity in my API, but I have some error that I believe is dependency injection. I made all the necessary configuration, connected with the bank, managed the…
-
0
votes1
answer38
viewsHow to show the data on the front end using Razor pages?
I’m a beginner in development. net core and I am developing an application that consumes data from an api and shows to users, but I don’t know how to show the data on the front end. I am using REFIT…
-
0
votes0
answers18
viewsAzure Function Queue, how to pick up 1 dice at a time?
Hello, good(m) (day, afternoon, night) I am working with a Function that when activated makes a very heavy processing. Because of that I can’t let her pick up multiple dice in the queue, it needs to…
-
0
votes1
answer209
viewsNullreferenceexception: Object Reference not set to an instance of an Object. How to resolve?
I am developing an application that consumes data from an API and shows to users, but I am facing an exception: NullReferenceException: Object reference not set to an instance of an object. How do I…
-
0
votes1
answer105
viewsUse of unassigned local variable. How to resolve?
I’m developing a site that requests an api and shows the data to users, but I’m having problems: Use of unassigned local variable 'value' Use of unassigned local variable 'date' To better…
-
0
votes1
answer56
viewsHow to query Data values on a C# connection to excel using Oledb?
Follow below the line of code private void button7_Click(object sender, EventArgs e) { string conex = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + textBox1.Text + ";Extended Properties=\"Excel…
-
0
votes0
answers87
viewsVisual Studio Connection 2019 c# with Firebase
I tried for hours and even days to look for application examples for VS 2019 connection extensions (in C#) with Firebase, but without any success. I feel that almost nobody uses it for lack of more…
-
0
votes1
answer44
viewsHow to return a JSON in ASP.NET API that has another JSON inside?
I don’t know if my question expresses well, but the kind of feedback I need is something like this: [ { "Id": 0, "Name": "string", "Image": "string", "Why": "string", "What": "string",…
-
0
votes1
answer41
viewsI can’t handle exceptions in the Controller on an ASP.NET API
In the code below I am trying to change the status of the request when I could not find the Project ID. // GET api/values/5 [HttpGet("{id}")] public Project Get(int id) { try { var project =…
-
0
votes1
answer61
viewsC# LINQ Join with OR condition?
I need to write this SQL in Linq, but in that condition JOIN is what gets me. SELECT * FROM Boleto_Retorno AS BR LEFT JOIN Recebimentos AS R ON SUBSTRING(BR.CH_NossoNumero,1,11) = CASE WHEN…
-
0
votes1
answer27
viewsPOST method in the ASP.NET Controller API is auto-incrementing foreign key even if the value should be empty
I have the following code: public ActionResult Post(Project project) { try { _acess.AddProject(project); } catch(DataException ex) { BadRequest(ex.Message); } return Ok(); } Sent JSON object: {…
-
0
votes1
answer31
viewsI cannot return ID when entering data via ASP NET Controller POST
I have the code below, and I need the ID returned as soon as I insert the object. If there is already a registered project, it does not do the insertion, but I need to return some data as empty or…
-
0
votes1
answer41
viewsShow grouped data in view
have the models department and institution, how do you see yourself next. public class Institution { public long? InstitutionId { get; set; } public string Name { get; set; } public string Address {…
-
0
votes1
answer41
viewsLosing values entered in the list after exiting the method (C#)
Good night! I started my learning in C# less than 3 weeks ago and I’m having trouble trying to manipulate lists. It’s a very simple console application. I have a menu where the user selects between…
-
0
votes1
answer37
viewsInsert values into a Chart via a button
I’m making a chart through a Chart, which when clicking on a button it searches the data and inserts it into Chart. But every time I click on the button it creates a new Row (as the image below).…
-
0
votes1
answer38
viewsHtml.Displayfor() not breaking string line
In this code, the idea is to generate a list of records searching the database and showing in a cshtml the variables, for each item in this Model. In the Database, strings contain \n (line breaks)…
-
0
votes1
answer99
viewsGET method returning empty
Good evening, I am developing a Webapi, I am using the code-first approach, for this I have selected the Entity framework 6.0.1, in my project I have the following classes Personcontroller.Cs,…
-
0
votes0
answers12
viewsError retrieving Client Data for Editing - C#
Friends, I have a table "person" and "address", I can register a customer and insert their information in the two tables, but I’m having difficulty to consult the customer’s information and bring it…
-
0
votes1
answer87
viewsC# and MS SQL Server Special Characters
I have a table of municipalities within the system, MS SQL Server database, and the names of municipalities are accented. I am consuming an API where municipalities come without any accentuation, so…
-
0
votes1
answer41
viewsSelenium search functions act faster than page loading
I automatized so that they were inserted email and password, and then clicked on "Login", until then your well, but the button that should be clicked after the login has not finished loading and…
-
0
votes1
answer21
viewsBinding of an Image in the Preject Resource
Good morning, you guys. I’m making a weather app for the course I’m doing and the weather icons we pull direct from links on the internet. How I would do it locally? The Icon is specified by an int…
-
0
votes1
answer111
viewsHow to access a global application.json variable in . NET Core c#
I am new with programming and I’m having difficulty accessing a Token that is as variable in the file application.json. It is a console application, the goal is only to use the token of the global…
-
0
votes3
answers307
viewsHow to save parts of a json in variable?
I’m new with programming and have a project in Console Application, which returns the call of an API the Json of it. I would like to know which command I can only get a part of json with. For…
-
0
votes1
answer32
viewsPass an array to a webapi controller
I’m having trouble passing an array to a controller via Axios. Example of the WEBAPI Controller code: [HttpGet] [ActionName("openshape")] [Route("api/shape/openshape")] public…
-
0
votes2
answers60
viewsHow to add the rest of the division to the last Value of a dictionary?
I have the total of a purchase list and need to divide this total by the amount of emails which I have on my second list and return a dictionary. However, not all division is exact, so I need to add…
-
0
votes2
answers78
viewsHow to create a dynamic selectable list on an object in Unity?
I would like to create a list that would appear when the user clicks a button. The list would show the information contained in the database, and the user would select which one would give…
-
0
votes0
answers32
viewsStatic method does not recognize fields in aspx
This method needs to be Static [WebMethod] public void ValidaSenhaAntiga(object sender, EventArgs e) { long CPF = Helper.DFrmtCPF(cpf.Value); string senhaAtual = SenhaAtual.Value; bool senhaAt =…
-
0
votes0
answers39
viewsCharacter does not follow mouse arrow. UNITY C#
I am creating a game in Unity and I made a code in the point() function for my character to point the gun in the direction of my cursor always. But it’s not happening. using System.Collections;…
-
0
votes1
answer39
viewsError converting an Enum
Good evening guys, I’m new in C# and would like if possible a help, I created an Enum with client codes and I’m trying to pass its value through a validation and I’m getting string to int conversion…
-
0
votes0
answers25
viewsBest Way to Implement Inotifypropertychanged
The traditional way would be to create a class where implements INotifyPropertyChanged and then inherit where you use it: public class NotifyPropertyChange : INotifyPropertyChanged { public event…
-
0
votes2
answers25
viewsHow to instantiate a class with predefined and immutable parameters C#
How to instantiate this class jogo? public class Jogo { public string Name { get; set; } public string Genre { get; } public string Plataform { get; } public Jogo(string name, string genre, string…
-
0
votes2
answers51
views"Argued tofrangeexception" error when performing database query to return quantity of records
I have a query in ADO . NET with the aim of return the amount of records I have in the bank based on last month and year. For example, I pass the date "27/01/2021" and receive the amount of records…
-
0
votes0
answers65
viewsConnection with two banks in c#
I need to connect to two types of databases, namely: Oracle and Postegre. I need to go to Oracle, generate a spool with some queries and upload this spool in Postegre. Is it possible to do this in…
-
0
votes0
answers25
viewsSending files via ajax to Webmethod
Good afternoon! I’m trying to send files via ajax for a WebMethod in c#, but I keep getting back my whole html page Javascript //Upload de arquivos $('#upload').change(function () { var fileUpload =…
-
0
votes1
answer57
viewsNullreferenceexception with Unity
I am having this error when trying to implement a theme search system in the database. The chronological order of events is as follows: A screen is shown for the user to enter the desired questions,…
-
0
votes1
answer76
viewsHow to write two Readline in a single line?
I was doing some tests and when I tried to do an example of date system, in the case of birth I came across the problem, that Voce can only write at the end of the Console.Write(), when Voce puts a…
-
0
votes1
answer145
viewsGenerate PDF and attach to send email c#
Good afternoon guys, I have a modal, where the user can send an email, in this modal, I loaded a HTML, so that I can generate the PDF and attach to send in the email. But I’ve seen several articles…
-
0
votes0
answers45
viewsSwagger returns error when climbing the API
I’m catching this mistake: Fetch errorundefined https://localhost:44358/Swagger/v2/Swagger.json When I only had one controller, Swagger would go up normally and I could do my tests and so on. Now,…
-
0
votes1
answer38
viewsHow do I verify that an entity is tracked with Entity framework Core 2.0.3?
In my repository, I need to create a function that returns a "boolean" informing me if an Entity is being "Tracked". I need to do this, because when I do an "update" of the same entity more than…
-
0
votes1
answer154
views -
0
votes2
answers38
viewsC# method with Procedure name and other parameters
I will be as soon as possible in my question which is the following: I am working on a scheme where my C# program will list the names of the procedures and their respective parameters that were…
c#asked 3 years, 9 months ago Leandro Azevedo 303 -
0
votes0
answers25
viewsuse yes in access and c# using checkbox in c# greenmark or false
I am creating a quiz and the questions are repeating. I intend to use the checkbox when checking whether or not the same checkbox has been used. I’m using the following code: int[] num = new…
-
0
votes1
answer32
viewsBringing a Controller Query to the View
I’m starting to venture out and learn about MVC and C#. I created a movie catalog application with a tutorial, where I have a table in the database called Movie and in the application I do a CRUD in…
-
0
votes0
answers20
viewsHow to join values from 2 datagrid’s to only 1, even though these columns have different sizes?
string[] datasald = new string[dataGridView1.Rows.Count + dataGridView2.Rows.Count - 2]; string[] debitosald = new string[dataGridView1.Rows.Count + dataGridView2.Rows.Count - 2]; string[]…
-
0
votes0
answers29
viewsHow do I "Count" larger XML nodes (Xelement)
Oops, how are you? I’m seizing C# on my own (after being initiated into python programming at the university). I’m trying to create 1 software that reads an XML file and wanted to split the file the…