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
votes2
answers165
viewsHow to take the first character of a String and make it uppercase by storing it in a variable?
String user,newUser,newPassword, password, resposta, user1,pass1; user = "admin"; password = "123"; Console.WriteLine("LOGIN\n"); body: Console.WriteLine("Ja possui…
-
2
votes2
answers311
viewsReturn Value ID C# Npgsqlcommand
After inserting a row of information in a given table, I need to recover the ID value to fill my object, my code is like this: using (NpgsqlConnection pgsqlConnection = new NpgsqlConnection(conn) {…
-
2
votes1
answer71
viewsProblem getting information from the Azure Cognitive Service (OCR)
I’m developing a windows service that downloads a web image, "flips" it horizontally and sends it to the cognitive service of Azure (OCR), the idea is to capture the text of this image. However,…
-
2
votes1
answer131
viewsGenerate multiple PDFS via Itextsharp
I am developing an application that builds pdf’s dynamically through the Itextsharp library. It is working and providing the download correctly, but would like to generate a larger amount of…
-
2
votes3
answers257
viewsSecurity Exception on UOL Host
I developed an ASP.NET MVC application that runs perfectly on site. When climbing it to UOL Host, when accessing the page (www.manuelaibi.com.br) I have the error Security Exception... It is…
-
2
votes1
answer437
viewsPass controller error to view
I am making a basic login form and I find myself in the following situation: I want to return an error if the user does not exist in the database and am doing so using "Modelstate.Addmodelerror".…
-
2
votes1
answer116
viewsSave Phone Array to Database
I created a table of Clientes and two from customers who are ClientesTelefone and ClientesEmail in my form I am generating email fields and phone dynamically, so I would like to know how I can…
-
2
votes0
answers74
viewsModel not being fully validated
Good morning Guys, I’m testing an application to add a client, but whenever I try to add the user, test the Viewmodel to see if the information is consistent, but the program does not validate all…
-
2
votes1
answer52
viewsHow do I pass the value of the Tumb variable to my controller?
How do I pass the value of the Thumb variable to my controller? The two input fields then pass normally, but the Tumb variable has to pass the video Image Url. Controller [HttpPost]…
-
2
votes1
answer46
viewsC# WPF Binding a 2 Radiobuttons as per a Boolean
Good staff. <GroupBox Header="Tipo de operação" HorizontalAlignment="Left" Height="55" Margin="10,70,0,0" VerticalAlignment="Top" Width="296"> <Grid x:Name="gridOperationType">…
-
2
votes1
answer82
viewsBrowse and retrieve DOM objects via getElement without using Webbrowser
Is there any way to browse web pages, create requests like .Document.getElementById(" ") without the need to use the component WebBrowser() on my form? WebBrowser browser = new WebBrowser();…
-
2
votes1
answer165
viewsHow to show / hide a button inside a listview
Man ListView is populated with data that comes from an API, but within my template I have a label statusDescr where it shows two states ("paid" / "canceled") when the status on the label is paid the…
-
2
votes0
answers36
viewsHow do I open a specific PDF page with Xamarin (iOS)?
I use the following code to open a PDF document. I would like to know how to open the PDF on a specific page, because every time I run the code, the document opens at the beginning. public void…
-
2
votes1
answer86
viewsget the values of a generic list List<t>
My project Winforms C# has a form with a GridControl(gvDados) and a button Sue with an event Click(). Validation takes place in the event Click from the process button, through a method responsible…
-
2
votes1
answer693
viewsCommand to open cash drawer
I’m trying to make a button that sends a command to open the cash drawer connected to the Tanca TP-650 printer. Below is the method I’m trying. public static void abrirGaveta(bool flag) { if (flag…
c#asked 6 years ago Gabriel Henrique 175 -
2
votes1
answer235
viewsXAMARIN - List View with Binding without Information
I’m doing a project with Xamarin.Forms and I have a problem. The project is related to the bus route of my city, but when making the code and playing to the screen, as much as it has BINDING the…
-
2
votes1
answer49
viewsI am validating a field of Cpf and need to make a check in the database if this Cpf has already been registered if it brings the message to the user
//verifica cpf válido jQuery.validator.addMethod("verificaCPF", function (value, element) { // tamanho do cpf if (value.length < 11) return false; // retira pontos, virgulas e…
-
2
votes1
answer38
viewsStructure of a Webservice X Model Class
I need to make a web service (asmx) where the Request Entry is in this structure: Input XML (Request) <RetrieveDeviceParentRequest> <model query=""> <keys query="">…
-
2
votes1
answer635
viewsC# - Multiple keys in JOIN LINQ Lambda Expressions
I have an SQL as follows: SELECT * FROM KY_AR_SOLICITACAO A JOIN KY_AR_SOLICITACAO_ITEM B ON A.NF_ENTRADA = B.NF_ENTRADA AND A.SERIE_NF_ENTRADA = B.SERIE_NF_ENTRADA AND A.NOME_CLIFOR = B.NOME_CLIFOR…
-
2
votes2
answers86
viewsLimit index query but not combo query
Good afternoon, In the company’s ERP we have a query in the Index that is limited to 80 records. The problem is that in create we have combos that bring more than 150 records and is also limiting to…
-
2
votes1
answer64
viewsDifference between property declaration in C#
I’m studying C#, very beginner, and I came across something, the course I’m doing has video lessons from 2015, and it passes me to create a class with attributes and properties like this:…
-
2
votes1
answer147
viewsHow to know which part of the code an exception happened by looking at Visual Studio Output
I realized that in some requisitions the output of mine Visual Studio displays some messages such as this: Exception generated: 'System.Collections.Generic.Keynotfoundexception' in mscorlib.dll…
-
2
votes1
answer378
viewsHow to redirect user to a specific page after login
I am able to login by type of user: administrator or common. And I am using: [Authorize(Roles = "Administrator")] and [Authorize(Roles = "Common")] Inside the controllers I want to restrict by type…
c# asp.net-mvc login authentication forms-authenticationasked 5 years, 11 months ago Rodrigo Santos 159 -
2
votes1
answer839
viewsHow to call a modal in the View from the Controller Actionresult
To call a modal from the Controller’s Actionresult, after the user clicks the button to register? The controller is currently redirecting to the index page after the user registers. I want instead…
-
2
votes1
answer282
viewsUpload Image, and Create a Thumb of the same Asp.Net Mvc Image?
I have a class called image, where I have two attributes, UrlDaImagem, and UrlDoThumb, I can save the image, normal only I would like to create a Thumb for that same image, without having to do a…
-
2
votes1
answer158
viewsError generating production report - Reportviewer Version 11
I am working with webforms and generating a report in reportviewer locally, the report accepts parameters and has a dataset // Parametros List<ReportParameter> parametersReport = new…
-
2
votes1
answer93
viewsmy Bubble Sort does not work well nor a
Code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp4 { class Program { static void Main(string[] args) {…
-
2
votes3
answers458
viewsHow to Update to Linq?
My project has the Delete method, only it definitely deletes the table record in the database. I would like to instead of delete, change the column record, I have a field called "Status", this field…
-
2
votes0
answers266
viewsHow to avoid Database Lock using Entityframework Transaction
I have a method where I save several classes and call another method to do an optimization on top of these classes, but I am using Transaction, in case something goes wrong in this optimization I…
-
2
votes2
answers209
viewsSlow problems with AJAX in ASP . NET MVC C#
I have a problem of slowness in my AJAX response. I use the following code to search and return a list of results: Javascript function enviaBusca(url) { var resultado = $('#resultados'), mensagem =…
-
2
votes2
answers709
viewsHow can I execute a function that is in another form?
I’ve got two presses, one of them I’ve got: namespace J13_Rouparia_CS { public partial class frmMain : Form { public static int LocPesq; public static string peqNume; public static string peqArti;…
-
2
votes1
answer66
viewsUse lambda expressions to sophisticate the parameters of a for in c#
good afternoon! I would like to ask a question, I am developing a collection code and at a certain time it is necessary a to iterate the values of the list and then save the information in an…
-
2
votes1
answer56
viewsProblem when deserialize json with $
Follows code json: { "_id": { "$oid": "5b0f4a926724c71d945299f9" }, "_class": "notificador.domain.entity.mongodb.WebhookNotification", "externalId": "EVE-XXXXXXXXXXXX", "resourceId":…
-
2
votes1
answer60
viewsError debugging by null on connection
I want to document a unit test but I’m getting error: System.Exception: 'Error closing database connection: Undefined object reference for an instance of an object.' My test case was so coded: using…
-
2
votes2
answers679
viewsHow to pass a parameter from one Action to another Action in the same Controller
I need to send a parameter from one action to another action in the same controller, but the parameter is "reset". How can I do this? Down with the code I’m making: [Authorize] public class…
-
2
votes1
answer38
viewsList contents of a list with a method
I have the following code: using System; using System.Collections.Generic; public class Program { class Candidato { public int numeroPartido {get;set;} public string nomeCandidato {get;set;} public…
-
2
votes1
answer72
viewsProblem Initialize List for ASP.NET MVC validation
I have an action that receives a user file. [HttpPost] public ActionResult UpdateFicheiro(FicheiroViewModel model) { var listaDeFicheirosJaAnexados = servico.obtemficheirosJaAnexados();…
-
2
votes2
answers177
viewsUpload file via FTP TLS
I am trying to upload files via FTP (TLS), but I am not successful because it always returns an error when my code runs "Connect()". I have tried using Ftpwebrequest , Ftpclient, Tamir.Sharpssh and…
c#asked 5 years, 10 months ago Cleber Pessoal 101 -
2
votes2
answers725
viewsLoad BLOB to Image C# Mysql
I am trying to load an image saved in Mysql, however still unsuccessful. With the code below I can display all other fields. Every time I try to add some method to display the image, some error…
-
2
votes1
answer104
viewsValidation does not enter the correct "if"
My code should have 4 validations and I’m using if and else if, but he’s only doing two of them, see the code below: double salario = 0; double p0 = 1.20; double p1 = 1.15; double p2 = 1.10; double…
-
2
votes1
answer181
viewsWhat is the difference between using "equals" vs == in LINQ to Entities?
As quoted above, when I say equals from LINQ to Entities I am referring specifically to the reserved word of C# and not to the Equals() of System.Object. Source: equals (Reference of C#) The…
-
2
votes1
answer83
viewsJoin to Linq c#
I have the following query in Sql Sevrer SELECT PT.id, P.nome AS Codigo, PT.topologiaid, TE.id AS TipoEntidadeId FROM [dbo].[propriedade] P INNER JOIN [dbo].[propriedadetopologia] PT ON P.id =…
-
2
votes1
answer517
viewsEFD-Reinf: Signature Error - A Xmldocument Context is Required for Enveloped Transformations
I am developing a C# application for the EFD-Reinf and at the time of sending my R-1000 event I am receiving the following message: "A Xmldocument Context is Needed for Enveloped Transformations."…
-
2
votes3
answers271
viewsI can’t do addiction injection
I’m working with ASP.NET CORE 2 and is a layered application. This is my ConfigureServices in the Startup.cs public void ConfigureServices(IServiceCollection services) {…
-
2
votes0
answers189
viewsGeneric Repository with Dapper
I’m doing a test application where I want to see performance and learn about creating a generic repository with Dapper, well I have some experience when creating a generic repository, but using EF6,…
-
2
votes0
answers95
viewsService with Filesystemwatcher does not listen forever
I’m doing a windows service in C#, which listens to a folder and every time it has an audio file it uploads. The problem is that it works, but after a few minutes of listening to the folder, it does…
-
2
votes2
answers386
viewseSocial: Invalid Subscription . NET Framework
Invalid Signature Good afternoon, I have a problem transmitting the information to the webservices of eSocial. The process I do is the following: the events Xmls are generated on the server,…
-
2
votes2
answers498
viewsC# Read TXT file and delete
Good Afternoon, I am developing a program that reads a certain file (contains more than 60k lines) removes unnecessary use and organizes and writes to another file. using (StreamReader leitor = new…
c#asked 5 years, 9 months ago Guilherme Palange 147 -
2
votes1
answer44
viewsWhat is the most efficient way to obtain a property from an Entity?
I’m using the EF6 and would like to know how to get the best performance when redeeming a unique property from a Entity. Assuming the following case: Let’s say I need to fetch all the names from a…
-
2
votes1
answer171
viewsList is not being passed as method parameter
I need to implement the method RoutesBetween to trace the route between a point and another (in this case, point To and And). Test method: public void TestRoutesBetweenTwoPoints() { var links = new…