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
votes1
answer201
viewsHow do I instate a class within a wpf?
The thing goes beyond that, the problem is that it always returns this error by instantiating this class: namespace AlmoxarifadoUpas { class ConsultaMaterialEntradaSaida { private…
-
2
votes1
answer262
viewsControllercontext Null
I have the following code: PDFController Ctrl = new PDFController(); byte[] ArquivoPDF = Ctrl.GerarPDF(xml); This part above is in the Webapi, where I create a new instance of the Controller to use…
-
2
votes0
answers121
viewsKeep object in memory after end of method
I need to load two worksheets to generate a dictionary with the worksheet data. I’m a little confused about this.. I created a Lerfile method to not repeat the code, since the process is the same…
c#asked 7 years, 7 months ago Gabriel Bernardone 563 -
2
votes1
answer129
viewsInstantiating generic type of an Enum
I would like to instantiate a class from an Enum, for example: Instead of doing: var classeGenerica; if (viewModel.tipoCarro == 1) classeGenerica = new classeCarro(); else classeGenerica = new…
-
2
votes2
answers172
viewsInitialize variable in a "for"
I remember that in C language I didn’t need to initialize the variable (in case i) with a value, I tried to do the same on C# and got a build error. In C# I am required to set the value of the…
-
2
votes2
answers338
viewsHow to put html id tag with variable name using Razor
Hey, you guys. A very silly doubt, but it’s giving me a lot of headache... I have this snippet of html code using Razor in Asp net mvc, I want to merge the id of this snippet, like, "name + code…
-
2
votes2
answers75
viewsEntityframework recursive query triggering Exception
When performing the query with recursion an Exception is occurring: Equipe.RelatorioRH.Single(x => x.IdRodada == IdRodada) 'Entityframeworkdynamicproxies-Model' metadata is invalid. If you are…
-
2
votes1
answer133
viewsError in create Asp.net
Unable to decrypt anti-counterfeiting token. If this application is hosted by a Web Farm or cluster, ensure that all the computers run the same version of ASP.NET Web Pages and that the…
-
2
votes2
answers312
viewsAsterisk tree algorithm *
I have a problem in an activity, the activity would be to make an asterisk tree of the type: * *** ***** but with my code for (int i = 0; i <= 5 ; i++) { for (int j = 0; j <= i; j++) {…
-
2
votes1
answer160
viewsHow to pass more than one parameter to a Controller?
I am in need of a backup to pass more than one parameter to a Creation Controller. I have some models as below: Usuario : Brings the information of the user who opened the call ex. id_usuario,…
-
2
votes1
answer222
viewsAsp.net Sqlexception: The INSERT statement conflicted with the FOREIGN KEY Constraint
There is a question similar to this one, but it’s different ..... my doubt is where to find where it gets this information.. is it in the view form? or controller? There are several Partials views…
-
2
votes1
answer875
viewsHow to invert a positive number to negative and vice versa in C#?
How do I get the number typed by the user, whether positive or negative, reversed? using System; namespace POOTeste { class Program2 { static int Main(string[] args) { int numero;…
-
2
votes2
answers557
viewsDivide in equal parts c#
I have a class called customer, a call returns, and another call technicians. in a certain month period, I create returns for these customers. after creating the returns, I want to split for the…
c#asked 5 years ago Rafael Passos 527 -
2
votes3
answers104
viewsChange project c# . Net 4.6 to . Net4.5
Would have some way to change the summer of . Net used in my project to an earlier version ? In my project is with . NET 4.6 and would like to return to the version . NET 4.5 without having to redo…
-
2
votes2
answers47
viewsHow to access the data in a variable of type double[ , ] in C#
I’m studying C# and in a certain code I came across the following situation: double[,,] R = new double[_StatesMaxCount, 3, 2]; In all the time I’ve been studying, I’ve never seen this kind of…
-
2
votes2
answers279
viewsDownload PDF file by link in e-mail
I developed a function that passing the Item id it generates a PDF file. [HttpPut] public void GerarPDF(long idItem) { ....Função } It already works perfectly, I did the test through the Google…
-
2
votes0
answers699
viewsX509 - Key set is not set
I use the class x509certificate of C# to read a certificate A3 for the signature of XML, occurs that it was necessary to renew the certificate and at first nothing changed, continued same type, but…
-
2
votes1
answer75
viewsObject Type Declaration Doubt - Entity Framework
I need help in defining the correct class statement Follows my code: public void BuscaOcorremcias() { //Op 01 - Declarando um IList da Model IList<Ocorrencia> ocorrencias = null; //Op 02 -…
-
2
votes1
answer85
viewsChange default pages created by MVC in Visual Studio C#
When I create the controller and use MVC 5 Controller with views, using Entity Framework, the Index, Create, Edit, Delete and Details are created automatically with a default setting, and I have to…
-
2
votes1
answer71
viewsCodefirst Entity Framework database, 1-0.. 1, 1-N
I have 3 tables and need to relate them via code (Code First) I would like to know how to do this. I already have the following table codes: Tbhistoricoanalogic using System; using…
-
2
votes2
answers278
viewsSpecial character encoding before going to the SQL database
I am working with SQL Server 2008 and IIS7 to host my MVC website. For security reasons, the website on which I work at the moment does not allow strings with special characters like '<' or…
-
2
votes0
answers48
viewsHow many bytes has a decimal (18.8)
How do I calculate the number of bytes of one decimal? In my decimal case (18.8). Why decimal (18.8)? A: Because I will save exact values for bitcoin in my BD Recommends a better way than…
-
2
votes1
answer297
viewsEntity - Multiplicity Constraint violated
I don’t understand the reason for this error in Entity. Could you give me a help? Error: The role 'Occurrence_occurrence_target' of the Relationship 'Addresseb.Models.Occurrence_occurrence' has…
-
2
votes0
answers170
viewsProblem with Selenium x C# x Chrome
Good afternoon. I have a web application made in c#. I need to do an integration via Selenium with another site and I’m having the following problems: When instantiating the webdriver for Chrome…
-
2
votes0
answers829
viewsRunning a service: the following error happens. Newtonsoft.Json.Jsonreaderexception: Unexpected Character encountered while Parsing value
Framework 4.0 Code block that generates the error var token = Configuracao.Config.TokenAgrometrika; if (Configuracao.Config.ValidateTokenAgrometrika > DateTime.Now) return token; var autenticacao…
-
2
votes1
answer61
viewsHow does "Threadpool.Unsafequeueuserworkitem" work?
I’ve done some research but I’m not finding a more didactic explanation, since I have no experience with threads.
-
2
votes1
answer201
viewsUsing Sessao on a MVC controller returns error
I am trying to use session in an MVC application, I believe you are right but it is returning the error: Undefined object reference for an object instance when it tries to pass the value in the…
-
2
votes2
answers314
viewsDatasource Configuration Error in VS Community 2015 C# + Reportviwer + Mysql
good afternoon. having a tremendous difficulty solving this problem. I am in the distribution phase of an App and exactly today I had a serious problem. Generate a report Using Riportviwer and Mysql…
-
2
votes2
answers174
viewsFormatting values per Razor pages
I’m having problems formatting a variable through the Razor pages in C#. Let’s say that a variable called value receives the number 9.5723 (real nine and 57 cents), I need all decimals above 2 are…
-
2
votes0
answers132
viewsCommunicate with Arduino through the COM4 port
I created a code in c# to communicate with the Arduino uno. He has to pass me what the tag passed by the rfid reader and show in a textbox the value. I added the serialport1. Code:…
-
2
votes1
answer272
viewsOn which layer should I create constants in my application with DDD concept?
I’m using the DDD concept (Layers: Presentation, Application, Domain, Data and Crosscutting) in my ASP.NET Core MVC application and I was wondering about the best place to create my constants. In my…
-
2
votes1
answer1612
viewsVscode extension for showing errors
What extension do I use to show c# code error? Example I am using the code line Console.Write($"{_Nome} está passando \n"); regardless of the using System in order for the console.write to work,…
-
2
votes2
answers441
viewsHow to select a date in c#?
I intend to select by the current date, like: list all the data that was registered today in my table, I did this way and does not result in anything, does not generate errors or list any of the…
-
2
votes2
answers1105
viewsExcessive line breaking while creating file . txt C#?
I’m trying to generate a file .txt from a code list recovered from the database. However, when the file is generated, line breaks come out in excessive number, as shown below: The code is as below,…
-
2
votes1
answer40
viewsShow user-selected date using Monthcalendar
I need that when a user selects a date a Messagebox appears saying: Your class has been scheduled for [date] private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) {…
-
2
votes1
answer88
viewsExtract parameters from an SQL query
In the following query in any SQL SELECT * FROM TABELA WHERE CAMPO1 = :PARAM1 AND CAMPO2 = :PARAM2 I need to get the names of these parameters, PARAM1 and PARAM2 and store them in a list or array.…
-
2
votes1
answer57
viewsCannot implicity Convert type int to string?
I am here copying a tutorial and is giving an error that I am not able to solve. Error: cannot implicity Convert type int to string Code: label_nome.Text = "Funcionario" + num_funcionario;…
c#asked 4 years, 10 months ago devilonline 41 -
2
votes2
answers232
viewsInheritance with Entity Framework
I have a doubt in the inheritance part, I have the person and user classes. Person has its basic attributes and the user inherits from the person. So far so good is right. My problem is that in…
-
2
votes1
answer508
viewsPicking up a specific file in an FTP directory
I have two methods, one sends a file by FTP and the other consumes a file by FTP. The files have the dynamic name DateTime.Now each day a new file. example: collections-04-04-2017 16_00_19.xlsx In…
-
2
votes0
answers90
viewsLINQ with Left Outer Join in Manytomany
I searched a lot about LINQ and Extension Methods, but I did not find a solution for this query that I need to do. The fact is that I have the model below (I left only the entities used) and I need…
-
2
votes1
answer33
viewsSqldatareader Incompatible Databindtable does not implement Ienumerable
I have a problem showing the data of a column on sqlserver, to insert as x and y in my Chart in Asp.net. The problem is this, it seems the method (DataBindTable) is waiting for IEnumerable but my…
-
2
votes1
answer65
viewsHow to make a select that brings the data registered in a given week?
I intend to list all the data registered in a given week, someone can help me? I did something similar to the example below and it doesn’t work. public List<View_Venda> Venda_Semanais() {…
-
2
votes2
answers121
viewsError compiling project with VB 6. Pass to . Net
I am not a developer in VB. I took a project for 5 days, through a consulting, but it should be all in SQL Server. Well, it turns out, that some changes on screen should be made. I opened VB 6…
-
2
votes0
answers89
viewsHow to set language according to file . resx
I am aware of the existence of this question: Internationalization using ASP.Net MVC but I’m having some questions. I have these language files (I’ll have more in the future): The system in question…
-
2
votes0
answers442
viewsNULL field in date, passing as parameter to the database
I am willing to treat a field in my program to accept data NULL if this field is not completed, it would be CliDtNasc. I did the treatment in class with the if ternary and in the class properties I…
-
2
votes1
answer162
viewsLoad the combobox
When save a dice in the combo box, and in this combo box has two options (gasoline, diesel, alcohol, natural gas) When I select diesel and save it works normally. The problem is when I want to load…
-
2
votes3
answers191
viewsLogical operator || in C# does not work
I’m trying to do an exercise where in a range of 0 to 30 I want to know which numbers are divisible by 3 or 4. Working with a if for every situation works. But if I try to use the logical operator…
-
2
votes1
answer106
viewsMeaning of the parentheses in the instantiation in C#
I can’t understand the need for () to instantiate a class. Retangulo n1 = new Retangulo(); Is it the language’s own thing or has meaning behind?
-
2
votes2
answers200
viewsError validating with Regex
I am trying to format this text with regex but do not have the desired return: Of: "ST STN, SET J, ? SHOPS T-40 /T41, - TER-REO, SHOPPING & BOULEVARD KM 28.5 VALUE 450.00 CENTRAL." To: "ST STN…
-
2
votes1
answer162
viewsWhat does everything in this method do? (Mirror Audit in Entity Framework)
Well, following this excellent reply of the Gypsy, where he implements a form of Auditoria Espelho, where it is implemented in the DbSaveChanges() the following method: //Laço de repetição em…