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
-
1
votes1
answer213
viewsHow many classes can I put in one code?
How many "classes" I can add to my code? Let’s say I have the following existing command block: namespace _06_ByteBank { public class Cliente { private string _cpf; public string Nome { get; set; }…
-
1
votes1
answer129
viewsDatabase insertion problem - SQL
Follows the code: Update command works: int noOfRowUpdated = ctx.Database.ExecuteSqlCommand("Update Mapa set Geo = geography::Point(47.65100, -122.34900, 4326) where Id= 1"); What does not work is…
-
1
votes1
answer53
viewsLogic - Given 2 strings, how to know how many moves I make when turning the first string into the second
Hi, are you okay? I have 2 strings , and I need you to calculate the total of moves to become the first string in the second string string palavra1 = "gato" string palavra2 = "pato" replacing the…
-
1
votes1
answer76
viewsASP.Net - Javascript file compression / Text Gzip
Good afternoon, I’m having a hard time configuring traffic compression using the GZip. Below are the steps I have already taken to effect compression: I’ve already enabled windows features related…
-
1
votes0
answers163
viewsMapping issues in Microsoft.Entityframeworkcore
I am trying to create in a class two Mappings Manytoone using the Entity Framework, but I’m not succeeding, if I take either of the two mappings and leave the other, it works but if I leave the two…
-
1
votes1
answer233
viewsReportviewer does not load in Internet Explorer 11
I’m trying to open a report with the ReportViewer in the Internet Explorer 11 And the same doesn’t open at all. This occurs with the application published on an application server, but when I run…
-
1
votes1
answer68
viewsWrite to txt
Friends, I am trying to generate a txt, in which the user clicks on the button and automatically downloads it. It is already generating txt, but I would like to know how to write in it? string str =…
-
1
votes1
answer246
viewsEFD-Reinf XML Signature - "Badly formed Reference Element."
I’m new to the community and I’m developing a C# application for EFD-REINF. I had a problem with the subscription and I received a great help from Pedro in this link. I’m still not able to send XML…
-
1
votes1
answer215
viewsAssistance with Rotationing(Quaternion.Slarp) in Unity
I want to make my object rotate 120 degrees and set a time for it. But instead of rotating 120 degrees it goes to degree 120. How to fix this? Transform inicial; float tempo; float angle; void Start…
-
1
votes1
answer285
views -
1
votes5
answers1664
viewsI want to put the number of characters and put whether it even or odd
But my code is going wrong. namespace Impar_ou_parr { class Program { static void Main(string[] args) { string NumLetras; Console.WriteLine("Digite uma Palavra: "); NumLetras = Console.ReadLine();…
-
1
votes1
answer386
viewsReplace is not working C#
I’m replacing one code with another in each row that the code is found on. But replace simply doesn’t work, goes through it and the line continues the same way. As you can see in the image below, if…
-
1
votes1
answer48
viewsMapping with Entity Framework
Good afternoon, when analyzing a code I see in the mapping the following line: this.HasKey(t => t.IdEstudante); I understand what you do in practice but not theoretically, refers to the object…
-
1
votes2
answers126
viewsGooglemaps + c#
I’m trying to accomplish a request in C# using the package RestSharp, for geolocation information by passing the zip code. The request this way was left:. RestClient client = new…
-
1
votes1
answer56
viewsInsert data with related objects
I’m trying to insert an object containing a relationship. User > Enterprise First I need to get the data from User in View of Create I’m doing it this way: public ActionResult Create() { var…
-
1
votes1
answer64
viewsHow to pass information in Viewdata on Asp.net core MVC
How to pass information (product name) from my controller Products to my Products view index by Viewdata?
-
1
votes1
answer735
viewsMigration with possible data loss
When generating an update of db which results in possible data loss efcore shows the alert: An Operation was scaffolded that may result in the Oss of data. Please review the Migration for Accuracy.…
-
1
votes1
answer104
viewsWpf Modern UI Metro Chart Update Chart
I have the chart below where the first load works normally, but when I do a search and change the list it continues with the previous series. Ex: in the first load I have 8 items in the list and it…
-
1
votes1
answer1393
viewscall action method in the controller via a view script
I have an action inside my controller, to download an XML file, with the following signature. public Actionresult Export(int id){}, no understand on my page I have a button that calls a download…
-
1
votes0
answers34
viewsDoubt in Windows Form in C#
I’m a beginner programmer, I’ve had a few classes in Java and C++ college, and I’m trying to learn C# on my own. For this, I’m trying to make an application (Windows Form) that will have text,…
-
1
votes3
answers115
viewsPage rendering Asp.net Disabledcssclass
I have the following problem, I have this code on a page: <div class="modal-footer"> <asp:Button runat="server" ID="btnCancelar" Text="Cancelar" class="btn btn-sm btn-danger"…
-
1
votes2
answers1383
viewsAutomatic click at a certain time
I am new to C# programming and would like to know if there is any way to create a program that shows the local time in the format HH:mm:ss:mmm and allows the user to choose a specific time for a…
-
1
votes0
answers106
viewsReport in c#
I’m trying to develop a report(report) in C# and using the ReportViewer for display. I am using the SGBD Postgresql, and I’m unable to make the connection to the database and the report, to get the…
-
1
votes0
answers118
viewsNamespace error name 'Linqtodb' could not be found
I downloaded Linq2db.Firebird via Nuget and changed the file as per the tutorial: <#@ template language="C#" debug="True" hostSpecific="True" #> <#@ output extension=".generated.cs" #>…
-
1
votes1
answer149
viewssearch object list in Entity [LINQ]
I have a list of objects and would like to search 2 properties of that list in the database. with a list of primitive types I would do so: (from n in db.Tabela where…
-
1
votes0
answers30
viewsWindows authentication
My Windows authentication is getting lost with time. I do the following validation: if(HttpContext.Current.User.Identity.IsAuthenticated == true) dsHostName =…
-
1
votes1
answer86
viewsTimestamp in C# for persistence in Sqlserver
Is there any typing that already treats this in C# to perform persistence in Sqlserver database? I need to resolve the Createdat and Updatedat property. For each change, it will be stored in the…
-
1
votes2
answers69
viewsGlobalization does not work when deploying
I deployed an ASP.NET application on a machine located in the center of the United States and now it behaves as being American even with the instruction below in the web.config file:…
-
1
votes1
answer177
viewsEscrenvendo on the Async Island
How to make a Console program, while it processes some task it execute a writing on the console (like a counter) asynchronous? independent. In other words, he will be writing independently of other…
-
1
votes3
answers519
viewsSending temporary information between classes with C# 4.0 MVC 4
Working with a Solution VS 2015 that has 2 sites, "projectA.site.com.br" and "projectB.site.com.br", their views and controllers are in the same project, named as "WEB", developed in C# . NET 4 with…
-
1
votes0
answers60
viewsFaster parallel process but doubles billet number
I have a process that needs to go through a list of 3000 accounts receivable, generate a billet number and save. I made an approach in parallel that is much faster, but doubles the number of…
-
1
votes0
answers31
viewsHow to execute method in another form
I cannot execute a form 2 method through the form 1 button I call the form but the method does not appear public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void…
c#asked 5 years, 10 months ago user9426886 21 -
1
votes1
answer852
viewsChange framework from a version to a newer one
I have a project .NET(c#) created in Framework 2.0. This Solution contains 11 projects. Now I need to update everything to the Framework 4.7(most recent). What would be my procedure for this? Usage…
-
1
votes1
answer319
viewsRemove element from the list in C#
I have a list and I want that after the foreach from that list, remove all elements from it, the method RemoveAll() asks parameter, but I don’t know which parameter to pass. foreach (var lista in…
-
1
votes1
answer56
viewsFind the position of a letter using FOR
I’m doing a project that is as follows. The Program asks the user a text and a letter that will be searched within this text and I want it to return me the position. Ex.: If you put the word "Table"…
c#asked 5 years, 9 months ago Marcos Eduardo 29 -
1
votes1
answer986
viewsHow to join two different lists using LINQ and Where?
I have three classes: class Cid { public string cid { get; set; } //importo esse campo via txt public string descricao { get; set; } //importo esse campo via txt } class Relacionamento { public…
-
1
votes1
answer143
viewsOpen Form2 and Close Form1, making Form2 the main (without making it invisible)
Hello, I have the following problem: I got the forms FrmLogin and FrmSistema. When the user logs in to FrmLogin I open the FrmSitema, lathe the FrmSitema the FormPrincipal, and close the FrmLogin.…
-
1
votes1
answer186
viewsProblem when displaying one form within another
I’m having trouble displaying one form inside another through a panel. The point is that by modifying the state of the main form of WindowState == FormWindowState.Normal for WindowState ==…
-
1
votes1
answer149
viewsReturn Collection of Products according to Category
I am unable to bring the list of products that has at least 1 related category. //Classe public class EventoConfiguracaoViewModel { public EventoConfiguracaoViewModel() { Menus = new…
-
1
votes1
answer35
viewsConversion c# wpf Icollection and Observablecollection
I have a list Icollection Generica and need to convert to Observablecollection, so I do not know which class is to convert to ObservableCollection<MyClass>. I’ve been searching for that answer…
-
1
votes1
answer235
viewsC# - Subselect in Lambda and Linq
How to mount the query below in Lambda and/or Linq? select emp.cd_empresa AS ID, emp.nm_razao_social + ' (' + emp.nm_fantasia + ')' AS EMPRESA, (SELECT COUNT(con.cd_consulta) from…
-
1
votes0
answers134
viewsXML deserialization in C# is returning null array even when XML has data
I’m trying to deserialize XML <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"…
-
1
votes1
answer36
viewsConversion error when trying to popular a variable
I have it: model.Items = new List<CatalogItemResponse>() { qryMode }; gives error because qryMode is of type Catalogitemresponse and not a list of the Catalogitemresponse How to inputo qryMode…
-
1
votes1
answer110
viewsCode line in Unit Test that is not accepted by code coverage
I have a test routine where a certain line of code is not accepted by the coverage. This is a test to return Defaultvalue since the object calling it is null. This is the method being tested public…
-
1
votes1
answer416
viewsHow to insert arrays inside angular objects?
Let’s say I have a vehicle object that has the following attributes converting my class c# to Json: { "UsuarioId": 0, "TipoId": 0, "MarcaId": 0, "ModeloId": 0, "VersaoId": 0, "Quilometragem": 0,…
-
1
votes1
answer139
viewsSend External Login Data to Controller
I need to login through Facebook, I have the login page, which renders a @Html.Partial _Loginexternal Follow the code of both: @using EuVotoAf.Models @model LoginViewModel @{ ViewBag.Title = "Log…
-
1
votes1
answer505
viewsDisable selection for Datagridview c# Windows Forms line
Hello, thanks for your attention I want to know how to disable the possibility of selecting a line from a Datagridview Meudatagridview.Rows[Line disabled]. enable = false; I’ve tried the Frozen:…
c#asked 5 years, 9 months ago Gustavo Pedro 201 -
1
votes1
answer121
viewsConvert a text file to PDF without saving to a physical location
Well I made a method to convert a text file into PDF, but it saves the PDF on the machine. I wanted that the method returns a array without having to save the PDF to the machine or having to read…
-
1
votes1
answer1462
viewsSet margins and paper size with Printdocument
I need to print labels and I’m using the PrintDocument, only there’s a problem I don’t know how I create the page for printing. Ex. My label has 4 cm tall and 10 cm wide with margins of 0.2 cm. How…
c#asked 7 years, 10 months ago Junior Guerreiro 617 -
1
votes0
answers568
viewsUI and desktop development . NET
I am at the beginning of the development of a commercial application in C#, however, I have my doubts about how I will do the visual part of the application (UI). I’ve worked with Windows Forms and…