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
answer68
viewsHow to create an . exe that you don’t need to run as an administrator?
I made a script for a trainer for FIFA15, it’s more something to help the community, now I’m generating a version for everyone to be able to run. Follows the code: using System; using…
-
2
votes0
answers240
viewsInsert picture text into a Sharepoint Listitem
I create items in Sharepoint, with a WPF/C#app, as in the example: using System; using Microsoft.SharePoint.Client; using SP = Microsoft.SharePoint.Client; namespace…
-
2
votes1
answer367
viewsHow can I see the SQL generated by Entity Framework Core?
I am using version 3.1 of EF Core, and I am trying to see the SQL generated from this code: var query = Db.Set<Area>() .Include(i => i.Extratos) .Include(i => i.Coordenadas) .Where(x…
-
2
votes1
answer35
views -
2
votes1
answer81
viewsWhy declare Static for all methods of a Static class?
I was studying here C# until I got to the part about the static. The teacher shows that it is possible to use this statement in methods and even in the class itself. The problem is that when using…
-
2
votes1
answer57
viewsHow to transform boolean input values to string values using C# (MVC)?
I’m having trouble transforming values from a Toggle input into a string value to be stored in a BD. The goal is to make a Buy/Sell Toggle that shows the type of operation the user is entering the…
-
2
votes1
answer199
viewsWhat is the difference between "value types" and "Reference types"?
I didn’t quite understand these classifications among the types that a variable can contain that are value types (types of value) and Reference types (reference types) that exists in the language…
-
2
votes1
answer44
viewsIs there a difference between Task.Fromresult and Task.Factory.Startnew?
Given a method in precise return a Task<T>. Example: public Task<MyResult> Handle(); I can make the following implementations: Thus: public Task<MyResult> Handle() { for (int i =…
-
2
votes1
answer205
viewsTwo error connection in the Entity Framework class constructor?
I need to use the connection to two databases, using Entity Framework, on appsettings.json, I added this way: "ConnectionStrings": { "banco1": "caminhobanco1", "banco2": "caminhobanco2" }, and in…
-
2
votes1
answer39
viewsHow to convert 2,22292E+12 to 2222921601281
I have a method that returns a float (but I can change this return to the other if I need to) float mmc(int a, int b) { float num1, num2, x, y, mmc = 0; num1 = a; num2 =b; x = num1; y = num2; while…
-
2
votes1
answer66
viewsIdentifier in Apache Activemq
I’m trying to integrate a consumer into a queue that uses the message Broker Apache Activemq. However, to consume these queues you need to configure an identifier, user and password. I can’t set…
-
2
votes1
answer113
viewsDependency Injection and Generic Repository Windows Forms C#
I have a windows Forms application where I am trying to use dependency injection for some services, for this I did the following configuration initially in Program.Cs I register the services: static…
-
2
votes1
answer48
viewsfilter list of registered assets by room
I’m doing a heritage system, where I can register a heritage and link to it a room. In this system I have a tab of reports, where I have a field that I must type the name of a room and a button to…
-
2
votes1
answer81
viewsCondition does not work in a Setter method
Why does my code give the following error: The operator '>' cannot be applied to type operands decimal and double. Code: class Funcionario { public string nome { get; set; } public string…
-
2
votes0
answers58
viewsPreventing multiple threads for the same routine and the same user?
I’m developing a web app on ASP.NET Core MVC and some routines are called by clicking a button on the web page. It turns out you can push this button multiple times, so I need some…
-
2
votes0
answers69
viewsRunning console application (C#) on another Windows machine
I am developing a console application, where I read a file . txt and perform some routines of INSERT my database. The application running on my machine works normal, but when running my . exe on…
-
2
votes0
answers49
viewsWhat is the point of using await in asynchronous methods?
Studying on asynchronous/synchronous operations one point was not clear, which would be the use of the await in methods async as in this example found on MS’s own website. If the method…
-
2
votes0
answers81
viewsC# Convert.Frombase64string returns different from PHP base64_decode
I’m doing the Decode in c# of a Base64 to be able to generate a Qrcode, in PHP it works normal but in c# the return of the Decode is different. This Base64 is created and encrypted by Serpro and…
-
2
votes0
answers80
viewsCORS error with Signalr using Usecredentials()
As it says in the title, I have a CORS problem with the Credentials using Signalr, the error returned is: Access to fetch at https://localhost:54083/notification/negotiate?negotiateVersion=1 from…
-
2
votes1
answer217
viewsCannot convert implicitly type "System.Collections.Generic.Ienumberable<SS_API.Model.Project>"
Cannot convert type implicitly "System.Collections.Generic.IEnumberable<SS_API.Model.Project>" em…
-
2
votes2
answers58
viewsPass txtBox value to Label (between Windows Form Forms) - However, string is null
Good afternoon, I’m a few days cracking my head here. I’m developing an app with 2 Forms (screens). On the home screen is login, and the second screen is the app itself. I want to take the name…
-
2
votes0
answers35
viewsTransforming a 1xN Sql Server Table into an object in C#
I’m new to the forum and I’d like some help. I am trying to pass a junction of tables with client information to C# but am having problems turning 1xN fields into objects. I want to bring the fields…
-
2
votes0
answers50
viewsProcessing Data rs232
good afternoon! I need a help that would be another explanation in a certain way. I am doing homologation of an equipment that send data via rs232 however the equipment does not have a protocol that…
-
2
votes0
answers30
viewsExtract and execute a foreach loop resource c#
private string GetDialogs() { string temp = Path.Combine(Directory.GetCurrentDirectory(), "dlgs.exe"); using FileStream stream = new(temp, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);…
c#asked 3 years, 8 months ago Rhadamants TriboGamer 21 -
2
votes1
answer95
viewsWhen a calculation is made in C#, is the primitive type of the variable maintained in the result?
I’m creating a simple C# application to calculate some flight information, in which you have a class called Calculator containing the following methods: public static float GetDistance(ushort…
-
2
votes1
answer74
viewsWritten to command line via Lua, command line reading via C#
I was in need of some help with a code on moon, to generate parameters for the command line, and then collect them by another application, only in C#, to be more specific, I want to run a virtual…
-
2
votes1
answer52
viewsBest way to query the database using LINQ and Entity Framework
Hello! I need to make a query in the database, the scenario is as follows: I receive email and from it I seek the id user. About the bank, there is the table Contact, which has Nxn relationship with…
-
2
votes0
answers27
viewsContext User does not return username Asp Net Core 3.1 C#
I’m trying to get the username logged in by the User context inside a controller. I’m using Identity to manage login and JWT to authenticate requests in my controller. I can get the values:…
-
2
votes1
answer34
viewsASP.NET Core: session duration
I did a program in ASP.NET Core MVC, which has the class Startup as: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration…
-
2
votes0
answers23
viewsHow to update a subdocument in a mongoDB document with Findoneandupdateasync
I’m trying to add a subdocument to a mongoDb document, but even looking at the previous posts I couldn’t find a solution. My classes public class UserClass { [BsonId]…
-
1
votes2
answers1187
viewsHow to edit data from a Table after postback in ASP.NET?
I have a Table in a Web Form in ASP.NET and just below in the same form I added a Textbox in which you fill the fields to add a new line to the Table. The insersion part in the table works very…
-
1
votes1
answer111
viewsHow to check if one control is the son of another? "Control.Ischildof"
I have 3 panels: <asp:Panel ID="ParentPanel" runat="server"> <asp:Panel ID="AnnoyingPanel" runat="server"> <asp:Panel ID="P" runat="server"> </asp:Panel> </asp:Panel>…
-
1
votes1
answer158
viewsHow do I test Htmlhelper, Ajaxhelper and Urlhelper methods?
I wrote some extensions for the MVC helpers. The problem is that I don’t know how to test these methods since I don’t have these objects in a test unit. How do I test the methods I created?…
-
1
votes2
answers1412
viewsHow to turn a DLL created in C# to VB6?
I created a very basic DLL in C# just for testing. It looked like this: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using…
-
1
votes2
answers1066
viewsHow to change the URL that consumes a Webservice?
I have a Webservice written in C# and the client application (data collectors). Collectors consume Webservice to view information in the main comic. On every client I install my Webservice (Data…
-
1
votes1
answer145
viewsIs it possible to call the Executequery method asynchronously?
It is possible to execute the method ExecuteQuery asynchronously? Consider the following code: public virtual MyEntity MyMethod(string parm1, string parm2) { string queryString =…
-
1
votes6
answers2938
viewsI can’t get the value of an Asp:hiddenField in c#, it’s always empty
I’m having a strange problem here. I’m assigning value to a asp:hiddenField via javascript (already tested giving alert and it shows the correct value), but then when I try to get its value in C…
-
1
votes3
answers5780
viewsForm opening another form within a splitcontainer
I have a main form divided by a splitcontaniner. When I click on a button panel1, a form is loaded into the panel2. private void btnCadastrarConta_Click(object sender, EventArgs e) {…
-
1
votes1
answer2151
viewsProblem printing a report using Reportviewer
Problem I have several reports Report Services Client that when I try to print happens 2 possible errors: If not installed the rsclientprint.dll the following message appears when I try to print the…
-
1
votes1
answer170
viewsMake Sonarqube with Opencover ignore some C#classes
It is possible to configure Sonarqube with Opencover to ignore some classes of my project . NET?
-
1
votes2
answers808
viewsScaffolding ASP.NET giving error
The error is generated using VS 2012. When I try to create the Controller for my News using the Entity framework, I have tried several ways. o My database you can see in the server explorer on the…
-
1
votes1
answer538
viewsHow to import MDB file read and write to SQL
I am trying to import a MDB file, read this file and write to SQL. I’m already able to import the file and read, I just can’t yet take this data and write to SQL. If you notice the code I even…
-
1
votes3
answers2393
viewsXmldocument Exception: hexadecimal value 0x1a, is an invalid character
I have a project that reads an XML generated by another program in which I don’t have access to the source code. The problem is that the generated XML comes with a special character at the end, and…
-
1
votes2
answers2408
viewsHow to render two typed Views on an Index()?
I’m trying to render two views created with the scaffolding, one is for the Create and another is for the List. The idea is to join in index the following: @model BraveryBranded.ASP.Models.News @{…
-
1
votes1
answer883
viewsHow to call Actionresult from another Area with an html link?
Hello, I have a link in a View and I need to direct this link to a ActionResult that is in another Area of my project. Is a link from Sair to call on the a ActionResult Logoff.…
-
1
votes1
answer352
viewsProblem generating list in Viewmodel
I’m working on ASP.Net with MVC 4, and when doing a search/use filters I will present a list of resulting data. To better manipulate this result I created a ViewModel where I put information from…
-
1
votes1
answer562
viewsTimeout Session using Stateserver
I have an application in cluster who wear the Session, to give no problem I put another machine to serve Session Server and set up the web.config as follows: <sessionState mode="StateServer"…
-
1
votes1
answer82
viewsDoes ASMX Web Service contain an event to end the request?
I would like to make sure that at the end of all requests to my Web Service the Savechanges runs. Someone could help me?
-
1
votes2
answers1994
viewsGet Post Data in ASP.Net MVC
I’m using MVC in my application and in Views I am using several tools from Telerik. I need to get some information from a POST that I give in mine View. Segue View: <div class="div-grid">…
-
1
votes2
answers1634
viewsHow to create reports in Cristal Report with data from 2 or more tables?
How do I create reports by Cristal Reports, using a Dataset that contains more than one Table? With a table I can work normal, but when I insert more than one table the result of the Report comes…