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
answers279
viewsIs there a difference in how polymorphism is applied in Java and C# ?
I’m studying the concepts of POO and generated me a doubt. In Java I believe I can access all methods and attributes declared as public in a subclass even when using a superclass type variable to…
-
4
votes3
answers1052
viewsHow to filter a list type Ienumerable<> through another Ienumerable<>?
How to filter a type list IEnumerable<> passing a parameter of type IEnumerable<> preferably via expression lambda or linq? Based on the filter below I expect this result: {MundoId = 0,…
-
4
votes1
answer438
viewsPage shows only the files in IIS 7 MVC Application 5
I have a Mvc 5 application, for development I used IIS Express, everything works normally on it, but I am a problem to climb IIS 7. Still on my local machine, later I will take to Windows 2008. The…
-
4
votes1
answer335
viewsGet properties of a class with condition. C#
I would like to get the properties of my Parents object, but I would not like to take the property (States) of my Country class. I tried it the way it is in the "Test" class and I couldn’t because I…
-
4
votes2
answers227
viewsRemove "OR" condition from LINQ query
I have the following method: bool naoUsarNomeCliente = String.IsNullOrWhiteSpace(filtro.NomeCliente); long codigoExterno; bool naoUsarCodigoExterno = !long.TryParse(filtro.CodigoExterno, out…
-
4
votes1
answer964
viewsHow to delete objects within a list?
I have the following code: using (Context contexto = new Context()) { List<Cliente> listCliente = contexto.Cliente.Where(x => x.Status == 0).ToList(); } How do I delete this result from the…
-
4
votes1
answer79
viewsA list of a guy can’t pass as a list of his 'higher' type?
There are some entities in the application that I am developing that need to be sorted by a predefined routine. Thinking about it was created contract class, called ElementoOrdenavel and all…
-
4
votes3
answers2714
viewsFailure to log in to an IIS application when trying to connect to Sqlserver
When I run an application of the type website in visual studio, database connections work normally. But when trying to run IIS 7 to perform some tests, I get the following message: Unable to open…
-
4
votes1
answer727
viewsError closing serial port in c#
I am new in C#. I made a program, which keeps continuously reading the data from the serial port and showing in a textbox. Until then, everything works well. The problem occurs when I try to close…
-
4
votes2
answers2552
viewsClaims Identity MVC
I’m having difficulty implementing Claims to make user authorizations in my project, I’ve read a lot but I can’t execute it. I’m using in the project the Nhibernate.AspNet.Identity may be that for…
c# asp.net-mvc asp.net-mvc-5 asp.net-identity fluent-nhibernateasked 7 years, 3 months ago Eluander J. F. Lopes 400 -
4
votes1
answer386
viewsIs it possible for a program to modify its own code?
I was developing an artificial intelligence program with neural networks, but what always left me chained is that every time I open the program, it will have to repeat the entire learning path to…
-
4
votes2
answers94
viewsHow to perform a Where using Entity Framework
I have a web application that I need to present a list containing some data, for that, I created the Model: Crm_Analise: public class Crm_Analise { [Key] public int id { get; set; } public string…
c# sql-server entity-framework asp.net-mvc-5asked 7 years, 2 months ago Thomas Erich Pimentel 3,059 -
4
votes1
answer471
viewsHow does Polly’s Fallback work?
I’m trying to understand how it works Fallback by Polly, but I’m not getting the implementation right. From what I understand he executes another action if the first fails, but that’s not what is…
-
4
votes3
answers634
viewsHow to make my program consume less CPU without disturbing its execution?
I have a program that reads the memory of a computer process continuously (with the while (true)), but it ends up requiring a lot of CPU, arriving at 20% used, my question is, how to decrease CPU…
-
4
votes1
answer280
viewsDoubt about Design Patterns - Idempotency Messages
I’m trying to create an application example that can call a function/method and that after a certain time it checks if the process has already been executed, if not, call the same function/method…
-
4
votes1
answer528
viewsDetect proxy configuration in webrequest
Good afternoon my dear, I need to make a request for an api that stays in an external domain the local network, I perform this through a webrequest that was created this way: WebRequest myWebRequest…
-
4
votes1
answer264
viewsHow can I insert these characters into C#
How can I insert these characters into c# ┍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┑ │ │ │ │ │ │ │ │ │ │ └╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┚ I wanted to use them to create menus on…
c#asked 7 years, 2 months ago Amadeu Antunes 3,331 -
4
votes1
answer4507
viewsHttpwebrequest fault
I’m trying to consume a Webservice via Webrequest in c# and I just can’t get any response from the server. However, via Postman I get the answer using the same parameters. code: var JsonCliente =…
-
4
votes1
answer108
viewsHow to detect the mouse wheel?
I need to detect if the user is scrolling down the mouse scroll. I tried with the GetKeyState, but it seems that there is no way to pass as parameter the scrolling of the mouse scroll. I also found…
-
4
votes2
answers117
viewsStreamwriter class
My idea is to create a system to insert new employees through the method CadastrarFuncionario(), placing the class properties (ID, nome, CPF) inside a file names employees.txt. With the logic used…
-
4
votes1
answer95
viewsWorking with Sources C#?
I added the Dictionary Source to my project, now I need to convert it into a code dictionary, but it is bringing the null resource, someone can help me? List<string> dic = new…
-
4
votes1
answer682
viewsMaking the Insert in SQL Server in a float field?
I have the following problem in my code, I have a textbox that receives the value 0.900, only when I’m recording this value in the bank, it’s only recording 900, and I need you to record the 0.900…
-
4
votes3
answers390
viewsGet specific application memory usage
I need to get the memory and CPU usage of an application in c#, with the code below (using PerformanceCounter) did not get the same Task Manager value from Windows. PerformanceCounter cpu;…
c#asked 7 years, 1 month ago Marlon Pereira 465 -
4
votes3
answers388
viewsIs it possible to offer return options in a method?
As far as I know Overload in the creation of methods, which are execution options, example(very simple), a method where you have the option to pass 2 or 3 parameters calling the same function:…
-
4
votes1
answer549
viewsAjax Request Does Not Work - Success Does Not Work
I did the following function: $("#CategoryList").change(function () { $("#SubCategoryDropDown").empty(); $.ajax({ dataType: "json", url: '@Url.Action("GetSubCategory", "ProjectSubCategories")',…
-
4
votes1
answer278
viewsIterate over two List optimally - Algorithm Optimization O(n²) C#
I need to iterate over two lists and compare the values contained in both. But the way I’m doing it is taking a lot of time, because the greatness of my algorithm is O(n²), follow below more…
-
4
votes1
answer107
viewsBeginform from ASP.NET does not apply route mapping when making the request
I have a route problem(again), I use the ASP.NET MVC5, and I have the following route mapped: routes.MapRoute( "Search_route", "Home/Search/{search_input}/{search_input_category}", new { controller…
-
4
votes3
answers759
viewsThe null value automatically becomes 0
I’m doing a vehicle registration, I need it to register put that whenever a vehicle is registered the value zero instead of putting the value null, I tried by default, but it does not record the…
-
4
votes3
answers750
viewsIs it correct in a DTO class to have attributes of two or more tables?
I need to return in a REST data of two tables, to be consumed in an Android/IOS App, developed with Xamarin. As I return a DTO, I thought to bring in this DTO data of two tables, but I find this…
-
4
votes1
answer1263
viewsConcatenation of two chained lists
The problem is: Write a program and make a function to concatenate two lists of integers into a third list that must be returned by the function, in C#. My doubt is only on how to concatenate the…
-
4
votes1
answer126
viewsStack/Stack with priority in c#?
My teacher passed 2 exercises, the first was to create a stack (Stack) simple to run unit tests in this class: using System; using System.Collections.Generic; using System.Linq; using System.Text;…
-
4
votes1
answer593
viewsReturn message together with Unauthorizedresult
I am using . NET Core 2 to create a dependency that will be injected into an API. The idea is to create a middleware to control incoming requests and act according to a number of business rules. It…
-
4
votes2
answers401
viewsSimultaneous calls in Restful service
Hello, I’m having doubts on how to make fun simultaneous calls (about 100) in a REST service. The example of code I have is the following: using (var http = new HttpClient { BaseAddress = new…
-
4
votes2
answers2246
viewsHow to print from a web application to a local printer with C#
I need to program in web some resources that perform local impression, where text and commands are sent to a specific device without the user interaction. For example the issuance of labels on Zebra…
-
4
votes1
answer456
viewsProblems restoring a Postgresql database with C#
private void btnRestore_Click(object sender, EventArgs e) { if (clsB.ConectaBanco()) { //Executo a seguinte função para limpar a base de dados, para poder dar o restore. clsB.ExecutarSQL("drop…
-
4
votes2
answers1161
viewsHow to insert using Sqlbulkcopy with Entityframework
I have a method that adds almost 2000 records at once, I was using the Bulk Insert and it was working perfectly, but this extension is paid for. So I decided to use the Sqlbulkcopy class but I’m…
c#asked 7 years ago William Cézar 1,268 -
4
votes2
answers1153
viewsHypothesis tests with C# - Merge (sum) of values to find result
Hello, everybody. I need to solve the following problem using C# (ASP . NET MVC): I have a table in the database that contains ID and Value (decimal) as below: id: 1 | value: 100,00 id: 2 | value:…
-
4
votes1
answer127
viewsProblem for deletion of data from a spreadsheet
I have the following piece of code that connects to excel, where it will delete the data from a tab of a spreadsheet. private void AtualizarPerformanceEntrega() { try { string sFileXLSX =…
-
4
votes1
answer277
viewsFormatting chart values using Syncfusion for Xamarin Forms
I’m using the Syncfusion to create graphics in Xamarin Forms. Studying the documentation, I could not find a way to format the values of my chart, example: I want these values formatted for…
-
4
votes1
answer817
viewsUnity change the order of a game Object via code by C#
Well I have a Game Object called Party Frames. Inside it I have several prefabs with different names (their names are the character Ids) and are Uis of character faces. The only thing I want is to…
-
4
votes2
answers677
viewsIs it mandatory to open and close connection when entering data?
In a *loop* que fazInsert` in an Excel spreadsheet it is mandatory to open and close the connection ? I analyzed the following, depending on the amount of registration it may take up to 1:30 to do…
-
4
votes2
answers400
viewsHow do I know if the screen is in "Extend" mode?
I want to make a if to know if the screen is in "Extend". Example: (Win + P) How can I do this in C#: if (?) // só pode entrar no if, se a tela está no modo "Estender". { SegundaTela formulario =…
c#asked 6 years, 11 months ago Matheus Miranda 5,375 -
4
votes2
answers932
viewsHow to pass a large list of objects to API in C#?
I am passing a list of objects to my API in C#. When the list size is smaller, everything happens as it should. When the list is a little longer the list arrives empty in my API. When the list is…
-
4
votes1
answer619
viewsHow to get a Mac-Address from a local network IP using . NET Core on Linux?
I already have tools that can identify the Mac-Address of my network devices, since the 'server' or the application is running on Windows and . NET Framework. I’ve been using the following: using…
-
4
votes2
answers2531
viewsAPI request mails returning null
I have a problem with my code c#, I am trying to consume the Post Office API but the data is null. I found another tutorial on the internet that said to instantiate the class trace and grab the…
-
4
votes1
answer320
viewsHow to get the Commandtext from a Iqueryable?
I’m trying to catch the sql generated by IQueryable, but is returning: SELECT NULL AS [EMPTY] I expected something like: SELECT i FROM lista WHERE i > 20; Like I’m doing: IDbConnection conn = new…
-
4
votes5
answers212
viewsGet array object by description in index
It is possible to use the property of an object as an index of a array, as described in the example below? using System; public class Program { public static void Main() { var myObjectArray = new…
-
4
votes1
answer474
viewsCode to generate user password hash in Oracle 10G with C#?
I need to authenticate users in a web application in the Oracle 10g database, but the credentials are native to the database by running an Oracle Forms application already, and we would like to keep…
-
4
votes1
answer64
viewsCompiler indicates non-existent Enum that exists
I’m using the Mono compiler. When I tried to compile this: using static System.Globalization.CharUnicodeInfo; using static System.Globalization.UnicodeCategory; namespace AS3Kit.Lexical { static…
-
4
votes1
answer52
viewsHow to make a temporary powerup?
Hello. I’m developing a game in which the player throws some balls (shots), so I created a powerup that decreases the time between the thrown balls. I need to make the time between the balls back to…