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
-
4
votes2
answers167
viewsDeserialize Json string[] for string[]
I have the following JSON: {"TicketID":["116","114","112","108","107","104","102"]} When I try to deserialize string[] get the bug: Server Error in Application '/'. No constructor without parameters…
-
4
votes1
answer2980
viewsC# Console Application. Read Json File
I have a Json file and it always gives error when I try to read it. I believe because it is an array within another array and I cannot read. Json: { "map": [ ["S", "S", "S", "S"], ["S", "S", "C",…
-
4
votes1
answer212
viewsEntity Framework Query Many to Many
I’m starting to use the Entity Framework and I’m looking to make a query between two tables, Livroes and Autors, and their relationship is like Many to Many. I don’t know if it’s relevant but I’m…
-
4
votes1
answer2182
viewsThe call thread cannot access this object because it belongs to a different thread
Follows the code: private async void button_1_Click(object sender, RoutedEventArgs e) { var listenPort = 11000; var listener = new TcpSocketListener(); listener.ConnectionReceived += async (senders,…
-
4
votes3
answers655
viewsController Base Dependency Injection
Well I’m learning to work with the dependency injection now and I’d like to apply it to my project. But I came across the following difficulty, I have a controller base where it is inherited by…
-
4
votes2
answers888
viewsHow to get the row and column indexes of a list List<List<int>>?
I have a list that simulates a matrix (or two-dimensional array) that is structured as follows: List<List<int>> matriz = new List<List<int>>(); Whereas this matriz is…
-
4
votes1
answer219
viewsQuery Return - Generic Entity Framework Repository
I have a generic repository and I realized that it is taking too long to return a query with the selection of some columns of my database, the Query() method is as follows: public IList<T>…
-
4
votes2
answers99
viewsSave the same file at the same time in different threads
In my software I have a thread that every second updates the X file. This same file can also be updated through a user action that will be in another thread (may be at any time). My question is:…
-
4
votes1
answer1123
viewsRedirect URL on IIS 7.5
When publishing to the server (iis 7.5) the application: Eu tenho isso => http://meuip:8086 Mas preciso disso => http://meuip:8086/portal when or if created the iis directory with the name…
-
4
votes1
answer823
viewsWhat is the purpose of Concurrencystamp and Securitystamp in ASP.NET Identity?
The summary of both properties in the entity IdentityUser are in English: Concurrencystamp: A Random value that must change Whenever a user is persisted to the store. Translating would be something…
-
4
votes2
answers163
viewsFile.Exists and the accentuation
I have a system developed in Webforms (Eca!) that checks the existence of an image to then display it. Everything is working correctly, however, when the image path has accents, the method…
-
4
votes2
answers220
viewsStandard implementations in C#interface
I was reading about the new features of C# 8 and came across the Default Interface Implentations, i.e., standard implementations in interfaces. The code below exemplifies public interface…
-
4
votes1
answer92
viewsHow can Stack expressions handle stack variables?
I’m learning C# and I’m reading about Brazilian expressions. The question is: how does it work and why does it work? public delegate void Test(); public void Foobar(ref Test del) { int var = 10; del…
-
4
votes2
answers926
viewsHow to reference the webservices of eSocial by Visual Studio?
I already followed the instructions of this question read, reread, and repeated the tutorial by Pedro Gaspar. And I can’t get eSocial webservices referenced by Visual Studio. What I’ve done so far…
-
4
votes1
answer748
viewsHow to extract content from the Web (Web scraping) with C#?
I recently learned how to make web scraping and I got it on some sites, but others I can’t. I noticed that in some of the ones I can’t get there’s an "#", what that means? Let me give you an example…
-
4
votes3
answers124
viewsHow can I use or name constants for response type fields?
There are situations in which we have fields that represent a type of response, whether boolean responses sim and não, S and N or with multiple responses like the status of something. For example…
-
4
votes1
answer2127
viewsHow to add Microsoft.ACE.OLEDB.12. 0 to my app’s installer . NET?
Hi, I have an app that I programmed through Visual Studio 2017 using the Microsoft.ACE.OLEDB.12.0 to consult on files Excel and return data. Now that I finished the project I had to publish. But…
-
4
votes0
answers160
viewsHow to make the player move on "slide" in Unity?
I’m new to Unity and I’m doing the tutorial Roguelike 2D. By default the player will move, theoretically, using one of those coordinates per shift y+1, x+1, y-1, x-1, or just one block at a time.…
-
4
votes1
answer2112
viewsCommunicationexception: Error in client making HTTP (HTTP.SYS) request to third party Webservice
I’m developing for the eSocial for more than a year now, and, I am finding the following error in some customers, when trying to send to the service: System.ServiceModel.Communicationexception:…
-
4
votes1
answer533
viewsWhat is the difference between Task and async Task?
In the code below I wrote two methods, one with the return Task and another async Task. What happens differently in the execution of these methods since for one added in the construction the…
-
4
votes1
answer394
viewsValidating USB Serial Port Name
People, I am doing the approval of a scale in c#, I can make the communication via code all right, however when making the connection, I need to specify the name of the port, I have other connected…
-
4
votes1
answer94
viewsCustomizing URI templates using Odata
I am working on a project that contains the package Microsoft.AspNet.WebApi.OData, which offers a well-simplified implementation to support Odata V3 by simply using the Attribute…
-
4
votes1
answer134
viewsView 2 dataTextField in a Selectlist
Hello! I have a little problem to make a selectlist display 2 values in textfield. I have the following Selectlist which is stored in a viewbag: ViewBag.Account = new SelectList(new…
-
4
votes1
answer150
viewsHow to implement an abstract method with a generic class in C#
I am creating a functional Factory where I define what is its output type and what are the required implementation methods. With this implementation, when I try to use the object obj within the…
-
4
votes1
answer112
viewsHow to page a query in Azure Cosmos DB?
I’m trying to pay for a consultation on Azure Cosmos DB, reading this post: Paging through query Results in Azure Documentdb, got to the code: public async Task <ICollection <TEntity>>…
-
4
votes1
answer318
viewsEntity Framework is not interpreting my settings
I have a serious problem with Entity Framework. I have two tables: Módulos and Viaturas, both with primary key name ID (Database First). A car can have a Module, but it can also be null, the…
-
4
votes2
answers2252
viewsUnassigned variable in c#
The variable in the last console.writeline is giving that has not been assigned being that it was in ifs, I wonder why. string c, nome; double s, sn; Console.WriteLine("Escreva o nome:"); nome =…
c#asked 6 years ago Nathalia Dias 139 -
4
votes1
answer119
viewsConfiguration file save directory with User C#scope
Regarding the configuration files in the C#, I’ve always used the App.config only to record strings connection and some read-only variables, but currently I needed to modify some data at runtime,…
-
4
votes2
answers402
viewsUnity: character walks side by side instead of front
Hi, I have a question on Unity3d 5! My character, instead of moving forward, with WASD, he moves sideways. My script: using UnityEngine; public class PlayerController : MonoBehaviour { void Update()…
-
4
votes2
answers404
viewsQuery with Datetime Sql and C#
I’m trying to get you to return to me the patient of a particular day and time in command next: SqlCommand cmdSelect = new SqlCommand("select DISTINCT P.nome,P.codPaciente, M.codMedico, C.descricao…
-
4
votes1
answer267
viewsAccept only one comma in Textbox c# WPF
Hello I have my decimal textbox like this: <TextBox x:Name="TextBox" KeyDown="TextBox_KeyDown" Style="{StaticResource MeuTextBoxValor}" Height="23" Margin="1" Text="{Binding Peso,…
-
4
votes1
answer898
viewsServer cannot attach a header after HTTP headers have been sent
Good morning, I have the following code that I use to compress the controllers using the GZip. I log in to the system normally, but if I try to change registered company the following error is…
-
4
votes2
answers86
viewsProblem when changing field focus
I’m having a problem changing the input focus between the TextBox of my application. The problem is actually this: tb_Estados has a AutoCompleteMode = AutoCompleteMode.Append and a…
-
4
votes2
answers52
viewsHow to search for specific data on the same line?
I’m reading a file XML where I have to take the values of certain data that are on the same line, example: I have the following line: <"Row GenericKitName=\"12000\" QueryID=\"999\"…
-
4
votes2
answers210
viewsImprove function performance that determines whether it is palindromic
Objective: to optimize performance Description of the problem: I have a function that returns me if the word is a palindrome with true otherwise with `false, until then quiet, but need to improve…
-
4
votes3
answers470
viewsLeft Join with LINQ
I have two tables that come from different repositories. One comes from an API and I have one that comes from BD. I already have the two tables mapped to classes. I want to select all records from…
-
4
votes0
answers216
viewsFile config Serilog Sink Asp.net Core
I am using the Serilog log log library on ASP.NET Core 2.1 I am using based on the Serilog manual: https://github.com/serilog/serilog-sinks-mssqlserver Normally the configuration file is in…
-
4
votes1
answer83
viewsHow does the compiler know that class x is an extension?
In this example, I create a class extension method DateTime in the c#: static class DateTimeExtensions { public DateTime PrimeiroDiaDoMes(this DateTime data) { return new DateTime(data.Year,…
-
4
votes1
answer134
viewsConcatenate files according to the order of the list C#
I have a program that concatenates PDF files. First it does the SPLIT of all pages of each file and store them in a temporary folder. When I press the end button, it calls a function GetFiles() that…
-
4
votes4
answers1515
viewsTake a field value by id and put it into a variable
Hello, I have a field on a form that receives the id: "teste", how can I catch via javascript this value and put in a variable?? I found the following on the internet var str =…
-
4
votes1
answer172
views -
4
votes1
answer154
viewsProblem with exporting to Excel using C#
I am exporting a list to excel, it occurs that in one of the fields, "fiscal note number content" and very large, excel tries to format it, generating special characters. Is there any way to select…
-
4
votes1
answer332
viewsSwitch to lambda/Drum a foreach
I have this method with a foreach inside [Route("")] [HttpGet] [ResponseType(typeof(List<MarkupListResponse>))] public IHttpActionResult Get(int resellerId) { var catalogs =…
-
4
votes1
answer81
viewsDispose() - Resource Release or Memory Release?
After seeing the topic "I should always use Dispose?", I still had some doubts and would like to know more about. It’s no secret that it’s ideal to use the Using statement for objects Idisposable,…
c#asked 5 years, 6 months ago Victor Laio 2,043 -
4
votes4
answers152
viewsHow to know the exact line of a Nullreferenceexception error when creating a new instance of an object with multiple properties
That’s a question I’ve always had, but now I’ve decided to ask. If when creating a new object (as in the example below, Occurrencereport), the Nullreferenceexception error is generated, the stack…
-
4
votes1
answer107
viewsForeach in Datatable
Have a datatable and needed to make a foreach to change some values of this datatable public static DataTable TabelaAmbientes { get; set; } I was doing the following foreach: foreach (DataRow lista…
c#asked 5 years, 6 months ago Jeff Henrique 1,020 -
4
votes1
answer76
viewsData to string conversion
I’m developing a project and I’m having a problem with a date-to-string conversion (I believe that’s it). I am counting months between a date and another (algorithm obtained in this other question,…
-
4
votes1
answer767
viewsAccess methods from another Form
I have a form called TelaInicio where I have a method CarregarGrid() I would like to access this method through my other form Cadastrar I’ve left the method CarregarGrid()as public but still do not…
-
4
votes1
answer180
viewsCustom Data Annotations for validation
I want to create a Data Annotation to be able to check in ALL pages of my application if the user who is logging in already has 1 Condomínio registered, if there is no registered condominium it…
-
4
votes1
answer420
viewsHow to translate "Errormessage" from a "Custom Attribute"
I created a Custom Attribute which is valid only if a property CPF is a valid CPF, but when locating the application I noticed that my Custom Attribute were not having their messages located by the…