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
votes0
answers78
viewsList files from a folder via ftp with jquery ajax
I need to list files from a folder that sits in one ftp server, how do I access this folder ? The user must select a list item (<select><option></option></select>) called…
-
2
votes1
answer63
viewsList only future items in C#
I have a database with a list of shows registered with location, date and time, but I need it to return me on the admin screen only the shows that will still happen instead of listing all shows…
-
2
votes2
answers132
viewsHow to block Numberbox or Textbox characters
I have a form from DevExtreme and in this form I have a NumberBox which is from a telephone field, but this field accepts only números (obvious), . and ,, but the phone, it could be like…
-
2
votes0
answers79
viewsUnit of Work - Error: "Attaching an Entity of type 'Entityb' failed because Another Entity of the same type already has the same Primary key value"
These are my example classes: public class EntityA { public string Id { get; set; } public decimal AproveValue { get; set; } public string EntityB_Id { get; set; } public virtual EntityB EntityBs {…
-
2
votes3
answers38
viewsHow to instantiate Webheadercollection using object initializers?
I’m making a requisition with the WebClient and would like to know if it is possible to add a Header within the class instance WebClient, example: WebClient client = new WebClient(){ Encoding =…
c#asked 5 years, 6 months ago Leonardo Bonetti 5,313 -
2
votes1
answer135
viewsError while using Middleware
I’m trying to use Middleware, so that every time a user logs into the system it is being redirected to condominium registration screen, he can not use the system until you register at least 1…
-
2
votes1
answer473
viewsFiltering in Bogotá
Hello, I’m having a problem to perform filters on a DataGridView I am using Windows Forms and pulling information from a Mysql database to the DataGridView called dgvDados the information is being…
-
2
votes0
answers186
viewsC# application in visual Studio does not connect to Sql database via network
I’m facing a problem with my application. I made the application without any error, managed the installer, but when I run it, it does not connect to the bank via network, but in Visual Studio it…
-
2
votes1
answer197
viewsHow to separate sequence of numbers in an array
For example, the user places in a textarea "1234 5678 1011 1213" I made a system that puts point and comma in each space, now I need to know how to store a digit sequence in an array, so I can make…
-
2
votes1
answer52
viewsHow to translate a rdlc file using resx files?
I am trying through a rdlc files to configure to fetch translations from a Resource . resx file public static Stream TranslateReport(Stream reportStream, string partyId) { var reportXml =…
-
2
votes2
answers567
viewsMethod that takes 3 integer values per parameter and returns them ordered in ascending order as an array
I can’t get the array filled returned be printed class Program { static void Main(string[] args) { int valor, valor2, valor3; Maior maior = new Maior(); Console.WriteLine("Digite um numero"); valor…
-
2
votes4
answers737
viewsHow do I close the form I’m in?
private void BtnEntrar_Click(object sender, EventArgs e) { string login = txtLogin.Text; Conta conta = new Conta(); try { BLL bll = new BLL(); conta = bll.SelectContaByLogin(login); if(txtSenha.Text…
-
2
votes1
answer33
viewsReturning Internalservererror a Tuple list
I have the following code: public async Task<IHttpActionResult> Gravar() { List<Tuple<string, string>> statusRetorno = new List<Tuple<string, string>>();…
-
2
votes1
answer220
viewsC# problems loading Data Grid using Datetime
Good night. I have one dataGrid which I carry using Entity Framework, however in dataGrid my date appears MM/dd/yyyy, I want to remove the time and format the date to dd/mm/yyyy, and in the validity…
-
2
votes1
answer69
viewsFunction to check if the year changes
I have this code that almost works perfectly. I went to do a test, and when it arrives to generate in January, it generates for the same year, example it generated an invoice for 15/12/2019 and has…
-
2
votes1
answer663
viewsCheck if the driver has a public constructor without parameters
Someone helps me, I am creating a project and in the dependency injection part I am having the following error when I make a Postman request in my Api: An error occurred when trying to create a…
-
2
votes1
answer63
viewsSave Object to another object’s controller
I have a class Collaborator, and a class Addressee. the collaborator has an address. In my collaborator class I have a: public virtual Endereco Endereco { get; set; } [ForeignKey("Endereco")] public…
-
2
votes1
answer111
viewsSavechanges is truncating the decimal value
I’ll rephrase the question: I need to write to the database with four decimal places. For example. In the view I type a percentage value of 56.78%. In the bank should be recorded 0.5678. That’s why…
-
2
votes1
answer67
viewsAccess xml files from a directory c#
I have a function that receives an xml file as a parameter. public void lerXML(XmlDocument xmlDoc) { XmlNodeList xnCNPJ = xmlDoc.GetElementsByTagName("emit"); XmlNodeList xnNFE =…
c#asked 5 years, 5 months ago Gabriel Henrique 45 -
2
votes1
answer141
viewsHow to take an image in a folder at the root of the project?
I’m trying to get an image that is inside a folder in the project to use with "Default" if any user does not add the photo at the time of registration, but when trying to pass the url, the error…
c#asked 5 years, 5 months ago Igor Carreiro 1,917 -
2
votes1
answer105
viewsError concatenating more than 9 C#files
PROBLEM I made a code to concatenate (Merge) pdf files. The code works in full but when there are more than 10 files, instead of doing in order: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Does so: 1, 10, 2, 3,…
-
2
votes2
answers1749
viewsHow to browse a dataGridView and store the values in a List or Array
I have to enter some data into a datagridView and then need to recover these values and store in a List or Array, so that then I can send it to the database. Guys, I don’t know how to do this! If…
-
2
votes0
answers41
viewsWCF error time - Await Jquery Post
I have this method, which until then works well: $('#modelEditar').submit(function (e) { $.post($(this).attr('EnvioLote'), $(this).serialize(), function (json) { if (json.sucesso == false) {…
-
2
votes2
answers72
viewsDoubt about dll version
I’m having a problem with my Dlls A few screens is "System.ValueTuple.dll" My Packages.config is with the version 4.5.0. But when the project is compiled, it generates the dll with the version…
-
2
votes1
answer35
viewsDon’t call class Startup, Owin
My API is not calling my Startup class, therefore it does not call my controller via Postman. Startup [assembly: OwinStartup(typeof(GestaoFrotas.Security.API.Startup))] namespace…
-
2
votes1
answer56
viewsMethod to move picturebox in an array
I am creating a method in the game of Checkers that allows the pieces to move, then in a textbox I insert the position of the piece that I want to move and then stores the variable aux, and the user…
-
2
votes1
answer55
viewsCan I use Nhibernate with Docker?
I have a personal project on ASP.NET MVC core that supports Docker. I would like to use Nhibernate to persist and retrieve information. In my searches I have not found anyone who uses. I am trying…
c# asp.net-core docker nhibernate fluent-nhibernateasked 5 years, 5 months ago Henrique.Eichstadt 29 -
2
votes0
answers133
viewsHow to read a text file on the INFRA.DATA layer of an Asp.net Core - C#
In the Infra.Data layer, I configured the properties of a csv file to be copied to the output directory of the "bin" folder and I would like to read it using the Streamreader class. After being…
-
2
votes0
answers22
viewsGeneric method for updating Cross-thread error form
I have a form where you need to do several updates using the thread-safe calls for Windows Forms controls Snippets of code that do this repeat several times. Trying to refactor I created a kind of…
-
2
votes1
answer277
viewsCheck if cookies exist in ASPNET CORE
I’m migrating from the Asp.net Webforms to the Core 2.2 and in the application, we stored information such as Id, and other parameters. In Asp.Net Core I use Seguinte Iactionresult to record the…
-
2
votes1
answer47
viewsError unable to access C#image collection
I am using Magick.NET to choose JPEG compression for my TIFF files. So, I save each one with this compression in a collection of images. Finally I want to join all the TIFF of the collection in one…
-
2
votes1
answer498
viewsIdentityuser Password Change - Aspnet
I have a registration form, which registers the user with email, and the password, but the need arose to change this password, and using the class Identity, she owns the field PasswordHash, and I…
-
2
votes3
answers749
viewsFormat string for JSON
I have the following code: public static string SendSMS(List<string> numbers, string usuario, string message) { int count = 0; string keerpersNumbers = ""; string urlSMS = "https://minhaurl";…
-
2
votes1
answer44
viewsFluentnhibernate is mounting the wrong query
Dear, After mapping the tables, I consulted one of them to return the information "daughter". The sql was mounted correctly, however the name of the key column (PK) was changed which made an error…
-
2
votes1
answer2081
viewsError instantiating System class.Nullreferenceexception: Undefined object reference for an instance of an object
Good morning, can anyone find the mistake I’m making by instantiating? I get that message back: Method error: Render : System.Nullreferenceexception: Reference to object not defined for an object…
c#asked 5 years, 5 months ago Thiago Piardi 21 -
2
votes0
answers27
viewsProblems displaying data from an automatically generated table because of the relation n to n, Entity framework c#
I am using Entity Framework code first in C#, I have the following classes. Procedure (only the relevant part): public int Id { get; set; } public virtual ICollection<Produto> Produtos { get;…
-
2
votes2
answers438
viewsRoute mapping does not work in ASP.NET Core 2.2
I have always used ASP.NET MVC 4 and now I am learning ASP.NET Core in version 2.2, I am doing some tests and I noticed that the routing is not working. I am using the standard design that is…
-
2
votes1
answer242
viewsAn Exception of type System.Nullreferenceexception occurred in Entityframework.dll when trying to insert given
I am trying to save a data in a table on the server using entityFramework, but is making an error of Nullreferenceexception. The insertion code is: public void CadastraFaleConosco(FaleConosco fale)…
-
2
votes2
answers361
viewsExport large amount of data to Excel
I have a DataGridView where in it there is an average of about 50 thousand lines where these should be exported to an Excel file. But because of the huge amount of data the application simply…
-
2
votes1
answer47
viewsChange the position of a Commandfield in gridview
I’m a beginner and I’m trying to create a dynamic table that can be edited and deleted certain fields so I decided to use gridview. The problem I cannot solve is the position of this commandfield…
-
2
votes0
answers29
viewsActive Directory login works for the second time only
I implemented an authentication via AD in my application. It only works on the second try, it does not work on the first. How do I resolve? DirectoryEntry directoryEntry = new DirectoryEntry(path,…
-
2
votes1
answer92
viewsAdd HTML Properties to an input via Razor
When I create a field input-type-text Via Razor, I do something like this: @Html.TextBox("nomeTxt", null, new { @class = "form-control", @placeholder = "Exemplo de placeholder", @type = "text" })…
-
2
votes2
answers112
viewsHow to select 2 records in an SQL Table in a given sequence?
I have a table with 100,000 records and the fields: id | dia | chuva_manha | chuva_tarde | chuva_noite I would like to create an instruction that consults the table and counts how many times a given…
-
2
votes2
answers110
viewsC# override autocomplete does not work
I can’t write a superscript with suggestions from override. The completion of the override does not give suggestions of virtual classes or methods as Tostring(). How do I make these suggestions…
-
2
votes0
answers53
viewsImport HTML to Datagridview [C#]
I’m working for the first time with HtmlAgilityPack for reading an HTML file that I’m manipulating. The idea is to take certain data from this file and insert it into the respective columns of my…
-
2
votes1
answer90
viewsSelect text in front of the current text using Textbox
I need that when a person type a word, automatically fills in front of the Textbox. This is the DEFAULT text For Example: sdfdsfasfColor this text in Textboxsdfdsassdf When I fill a piece of the…
-
2
votes1
answer515
viewsIntegration Test . Net Core 2.2
I’m creating an integration test using microsoft Tuto Integration tests in ASP.NET Core public class WebAppFactory : WebApplicationFactory<Startup> { protected override void…
-
2
votes1
answer1915
viewsError: Collection modified; maybe enumeration operation is not executed
I have a problem using the foreach to traverse a array of strings. This component is a search button to select files, it selects and writes the address of the file into a array of strings, i created…
-
2
votes1
answer138
viewsiTextSharp - Add TIFF image to a PDF
I am using Magick.NET-Q16-Anycpu version 7.12.0 and iTextSharp libraries. First I open the image with Magick and save this TIFF page in a folder. Then I use this image to add it to the PDF. I’ve…
-
2
votes1
answer186
viewsWhy is EF Core updating data from other tables?
Why EF Core is actuating data from other tables? I am updating a table with EF but however I notice that EF is updating that table and still other tables. public async Task<IActionResult>…