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
-
3
votes1
answer276
viewsInvalid Date and Time on signature using A3 digital certificate in C#
I’m having trouble getting the day and time to digitally sign a PDF document to P7S. I followed the documentation: https://msdn.microsoft.com/pt-br/library/ms148432(v=vs.110). aspx There are also…
-
3
votes1
answer155
viewsRetrieve data via JSON by URL in C#
I need to get data via JSON, through a URL, this link: https://cryptohub.online/api/market/ticker/egx/ I’m trying with the code below, but I already get error as soon as it downloads the string. The…
-
3
votes1
answer42
viewsConfiscate an EPS export to JPEG on Magick.NET
I’m using the library Magick.NET to convert an EPS file > JPEG. However the result is not pleasant because independent of the resolution (DPI) and size(Width and Height) that I put the image…
c#asked 6 years, 3 months ago Leonardo Bonetti 5,313 -
3
votes2
answers428
viewsText with line break
I pass some product instructions for an external charge service (website). On the screen of this site, the past messages are in the "description" field, inside an element h3, which seems to have 25…
-
3
votes2
answers406
viewsWhat is the purpose of the Interfaces used in a Mock?
I’m using a library called Moq which serves to create mocks that will be used in unit tests. However, to create a mock it is necessary to specify an interface, as in the example of the Moq project…
-
3
votes1
answer4561
viewsHow to send FORM values to the Controller in ASP.NET MVC?
I am new to ASP.NET and am creating an MVC application. I have in my controller a method that works as follows: public ActionResult ShowClients(string proc) { --(proc)EXECUTA ALGUMA LOGICA AQUI…
-
3
votes3
answers1061
viewsKnowing when your computer was Turned On / Off / Stopped
I wanted to know when the computer was switched on, off or interrupted. If I turned on my computer from today’s date, then I want to know the time and date it was turned on. On shutdown the same…
-
3
votes2
answers84
viewsUsing interfaces for domain classes
Is it good practice to make use of domain class interfaces? Do I have an advantage in doing so? If so, which one? Example: public interface IAuditoria { long AuditoriaID { get; set; } string…
-
3
votes0
answers99
viewsHow do I use the Visual Studio Authentication feature for an ASP.NET MVC project?
Gentlemen, I need an orientation to begin an ASP.NET MVC development project at Visual Studio. It relates to the implementation of the Authentication feature when creating a new ASP.NET project. My…
-
3
votes1
answer408
viewsdeserialize xml c#
I made a call through my web api and put in a class. How I display the values? xml: <result> <resourceName>activity</resourceName> <size>1</size> <entries>…
-
3
votes1
answer54
viewsIs it possible to interpolate a string already declared in C#?
The question What does the symbol "$" mean before a string? , explains that it is possible to interpolate strings in C# through the $ (dollar sign). However, I noticed that, in all cases where it is…
-
3
votes1
answer536
viewsProblem with Saving Image in Mysql C#
Hello! When saving the image, instead of going the file to the database with the right size, goes the following: Code inside the Visual Studio: private void button1_Click_1(object sender, EventArgs…
c#asked 6 years, 2 months ago Igor Souza 45 -
3
votes1
answer464
viewsHow to Replace Bar and Space by Dot and Comma in C#
I want to create a system that removes all bars and spaces per point and comma, for example 4587 / 5458 = 4587;5458 4587 5458 = 4587;5458 How can I create this system with C#? My code so far is like…
-
3
votes1
answer560
viewsTextbox masks value from 2 to 4 decimal places in WPF C#
I wish my Textbox had the following "mask" When I put two houses after the comma: 0,00 or when I put three: 0,000 or when I put 4: 0,0000 My code in WPF C# and the following: <TextBox…
-
3
votes0
answers35
viewsApplication in 3 layers X MVC
I was talking to a college roommate and he said something about application in 3 layers, I thought of something like MVC and researching a little more, really this application in 3 layers looks like…
-
3
votes1
answer517
viewsIf chained - how to eliminate?
I’m doing an application where I have the following scenario: I have several rules (business classes) where they all return the client code. These are separate classes that will look for the trial…
-
3
votes1
answer365
viewsRead Streamreader First Line or skip how to fix?
I have a file. csv and tou put the data in a datatable , but the problem I have at the moment is that it does not pass this data due to the first line it reads from the second column being of the…
-
3
votes1
answer248
viewsSize of a very large Xamarin Forms application
Recently created an application using Xamarin.Forms, but after the release it was with a size of 15MB. My app has a total of 8 pages (views) among which only two use images and speaking in images…
-
3
votes1
answer50
viewsReturn text sql to model in the Entity framework
I have the parent class and the state class: [Table("tb_pais")] public class PaisModel { [Key] [Column("id")] public int Id { get; set; } [Column("nome")] [Required(ErrorMessage = "O campo nome é…
-
3
votes1
answer249
viewsError return method "public async Task<string>"
When I run the code below, it gives error on this line: Literal1.Text= ObterEmocoes(imageFilePath); Is giving this error message: An object reference is required for the non-static "Program.Get…
-
3
votes1
answer136
viewsRefactoring Sonarqube code
What could I do to improve this code? Sonarqube indicates that I should refactor this code, but does not present any suggestions: var dados = Set.Where(s => s.Id > 0); if (filtro.IdSolicitacao…
-
3
votes2
answers143
viewsError #CS0176 in if statement, what am I doing wrong?
Why am I getting error #CS0176 when I call variable madeiras in (gamble.Equals("gamble {0}", madeiras))? From what I understand is because my method is static, and I need to put the name of your…
-
3
votes1
answer464
viewsExcel file reading with more than 1 sheet in the same file using C#
In this code I can read all the data of the spreadsheet Plan1 that has the name "Data" of the file ".xls", more if I have more spreadsheet in the same file, as I can read?. Code for reading: static…
-
3
votes1
answer328
viewsHow to validate the JSON schema in C#?
Follows json (has only 1 error, may have several errors): { "errors": [ { "code": "XX-55", "path": "customer.id", "description": "Cliente não encontrado" } ] } Another example of the return:…
-
3
votes1
answer52
viewsplugin.media error
I’m trying to use the Media Plugin for Xamarin and Windows with the Visual Studio Community 2017. An android app that should have the ability to take some photos. I followed the following…
-
3
votes1
answer106
viewsc# - Error trying to Replace a string
Boa Pessoal, I have the following problem: While trying to do the replace of a string (of a Literal Control), using the code below, the value of the code is not changed.…
-
3
votes1
answer123
viewsManage Datatable with lots of information
I have here a "small" problem with a DataTable. From an SQL query I am getting a huge amount of records (> 1,000,000), and although the consultation is relatively quick, the loading of the…
-
3
votes4
answers4102
viewsHow to return the values of a List<> in C#
I have a class Funcionario which has as attributes: CPF, Nome and Salario. I have to create an X amount of instances of this class in a List<> and after that, return to the user the values of…
-
3
votes0
answers59
viewsHow to get data from a table on a website?
I’m developing a program that captures the proxies and ports of this site, for the program to get the proxies I used regular expression and htmlagilitypack... However, how to get the doors? Since by…
c#asked 6 years, 1 month ago Alan Assis 97 -
3
votes2
answers110
viewsDatagrid show foreign key value instead of ID
I’m showing the data from a table(TB_LIBERACAO) in a DataGrid, however this table has 2 foreign keys from the tables TB_CARROS and TB_MOTORISTAS TB_LIBERACAO idLib idCarro(FK) idMotorista(FK)…
-
3
votes1
answer555
viewsASP.NET Core Pagination - Pagedlist.Core
I am creating an ASP.NET core study project, and when using the paging library PagedList.Core, the following error is occurring while running the command dotnet run: Startup.Cs(49,35): error CS0246:…
-
3
votes1
answer343
viewsConsume DLL made in Delphi 7 in C#
I’m in need of creating a DLL in Delphi 7 and consume it in C#, when the parameters and return are int there are no problems, the problem occurs when I try to use string in return, put in Delphi a…
-
3
votes1
answer199
viewsHow do I make my form work with reCAPTCHA?
I am saving the data by Ajax, however my reCaptcha is not working properly, the form is sent even without pressing inside the Captcha. My Controller [HttpPost] [CaptchaValidator(PrivateKey=…
-
3
votes1
answer182
viewsIndividual and Legal in the same table
Could you help me please ? I am developing a crud for client, where I will leave physical and legal person in the same table, but in case when the user chooses the type of person through a radio…
-
3
votes1
answer241
viewsAccessing a list/array in a JSON URL
I am sending via JSON an array of strings, how can I access this array via url? example of some of the tests: http://localhost:51746/api/Language/Getlanguagelist? key=[spool,error]…
-
3
votes2
answers51
viewsSave data from a Row to an array
I’m developing a new functionality for a project Winforms in C#. Soon I developed the following method that returns itself in the component GridControl (gvDados) there is a line selected or not.…
-
3
votes1
answer326
viewsHow to open an executable that requires elevation via C#?
The code provided below seeks to be able to open an executable file so that it is possible to pass arguments to it once it has been opened. For the code as it is displayed, error returned is:…
-
3
votes1
answer279
viewsCannot use tskill in C#
The tskill command when used via C# (Visual Studio) returns this error: 'tskill' not recognized as an internal or external command, a operable program or a batch file However the same command when…
-
3
votes0
answers113
viewsHow to use interfaces like Dbset’s in the C#Entity Framework
Hello, I’m making a solution where my entire business layer is in a separate project and in this project I created the layer relational structure from interfaces as shown in the example below: //…
-
3
votes1
answer49
viewsDo instances of the same application share static objects?
I am developing a Windows Form application in C#, and this application can run simultaneously several times on the same computer. And I am doubtful whether or not I should use static objects…
-
3
votes1
answer246
viewsSelection with Dapper using IN clause
My idea is to generate a search in my bank using the clause in through the Dapper. For example: select * from product where CasNo in(@filtro) Remembering that inside this @filtro has a list of Casno…
-
3
votes1
answer4757
viewsCompare two lists of objects and pick only the different ones
I’m having trouble comparing two lists of the same kind List<Produto> in my product class I have the following structure. public class Product { public int IdProduct { get; set; } public…
-
3
votes1
answer524
viewsHow to consume EFD-Reinf Webservice in C#? (Sending Events)
I am initiating the EFD-Reinf Information Submission Tests in C#. By Visual Studio, I added a Service Reference in my project with the URL:…
-
3
votes3
answers680
viewsHelp with Sqlquery in context Entity Framework
I need to make a return from my database in a specific way, but I have a problem, the situation is as follows: I have this query already tested directly on SQL Server, and is working perfectly:…
-
3
votes1
answer384
viewsAsparallel(). Forall vs async await
When to use AsParallel().ForAll, and when to use async await? I am providing an example with a download and file manipulation routine. The AsParallel().ForAll has better performance in the download…
-
3
votes3
answers272
viewsDeserialization of JSON
I’m having a hard time deserializing this JSON: string json = "{\"Cidade\":[\"Arrio do Sal\",\"Atl\\u00e2ntida\",\"Bom…
-
3
votes1
answer77
viewsWhat is the scope of variables on an ASP.NET MVC page?
I have a view layout: <div> <h1>Pagina Principal<h1> </div> <div> <h3>Simular<h3> </div> <div class="row">…
-
3
votes0
answers163
viewsFunction to validate xml
I have this function to validate an xml: public static bool ValidarXML(string pathXML, string pathSchema, ref string retorno) { bool falhou; // Define o tipo de validação XmlReaderSettings settings…
-
3
votes2
answers293
viewsHow to make a switch in C#?
I see a lot of people saying it’s wrong to do switch in the code, because it ends up weighing and is ugly. Is it correct the way I am using and what would be an alternative to using it? Fill the…
-
3
votes1
answer968
viewsInvalidcastexception: Unable to cast Object of type 'System.Security.Cryptography.Rsacng'
I am trying to pass the PIN through the code, so that the user does not need to enter it always, it is returning me this error: Invalidcastexception: Unable to cast Object of type…