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
answer892
viewsHow to use a Hotmail/outlook account to send email in c#
I am trying to use an account to send email, with my project in c#, using the namespace System.Net.Mail, however I can’t authenticate on outlook server, it throws me the exception:…
-
3
votes1
answer747
viewsHow to select information from multiple Datagridview C#lines
I’ve been messing with C# lately and I’m having a hard time. I want to get information from several selected lines on DataGridView, and, depending on the number of lines, pass this information to…
-
3
votes2
answers150
viewsHow do you register all validation classes with Dryioc?
How can I log all my validation classes using Dryioc dynamically ? I’m trying this way down; using DryIoc; using FluentValidation; using System; using System.Linq; using System.Reflection; namespace…
-
3
votes1
answer110
viewsDoes "Join" make the search faster?
I have two tables, one of patients and the other of consultations. In short, the tables have the following structure: Patients int id; string nome; string cartaoSus; Consultation int id; int…
c# entity-framework linq lambda-expressions linq-to-entitiesasked 7 years, 3 months ago Italo Rodrigo 4,344 -
3
votes1
answer66
viewsSimulate a Master/Detail report with foreach
I have a table as follows: public class Producao { string unidade; string profissional; string procedimento; } I can take all the records stored in the table and play them on a list listaProducao.…
-
3
votes1
answer10492
viewsWhen to use Html.Beginform() and why to use it?
I came across the following situation, in one of the views I have a search ground: <form class="navbar-form navbar-right" role="search"> <div class="form-group">…
-
3
votes1
answer845
viewsEntity Framework with Oracle
I am trying to use EF, using Code Frist, along with an Oracle database, for this I am using the Nuget package Oracle.ManagedDataAccess.Entityframework, but whenever I try to run the Update-Database…
-
3
votes2
answers280
viewsLoop is not repeating as it should
I am creating a code that reads the number typed by the user and, if it is from 1 to 10, it performs the tabulation, presenting value to value on the screen, besides allowing the user to choose…
-
3
votes2
answers1018
viewsHow to split elements of an array using the For loop?
Program Summary Good morning, I’m developing a calculator that asks the user for the amount of numbers that will be calculated, the operation and the numbers in question. To store the values, I use…
-
3
votes1
answer9941
viewsReturning difference between days and months
I am developing a C# function that calculates the interest applied to a given account. for this it is necessary to know the correct difference between days and months. How is it possible to execute…
-
3
votes1
answer270
viewsLock reading, opening and editing file
How to block the opening, reading and editing of a file by the user during the period the application is running? An application has a relatively long data collection period. This application reads…
-
3
votes1
answer37
viewsWhy can I invoke functions without parentheses in VB.NET?
In C#, this code does not compile: public static string Teste(){ string val = ""; return val.Trim; } Because the function Teste requires a return of the type string, and Trim is a MethodGroup. That…
-
3
votes1
answer423
viewsHow to print accent on a Console Application project . NET Core
using System; namespace MediaDoisNumeros { class Program { static void Main(string[] args) { Int16 numero1, numero2; Double media; Console.Write("Digite o numero 1 : "); numero1 =…
-
3
votes1
answer710
viewsTransforming synchronous into asynchronous method
I have the following method: public string MyMethod1(string myParam1) { // Implementação return myReturnValue; } I needed to create an asynchronous method that did the same thing, to process several…
-
3
votes1
answer1156
viewsUnable to create an instance of Activex control because the current thread is not in an STA
I’m trying to access a website through Webbrowser and this morning, suddenly, the following error appeared Unable to create an Activex control instance '8856f961-340a-11d0-a96b-00c04fd705a2' because…
-
3
votes2
answers289
viewsWhy doesn’t Return work?
I have a problem with return not work at all. For now I’m just printing on the console, so I’m replacing the return for Console.WriteLine(), but didn’t want to always have to do it. Here is an…
-
3
votes2
answers312
viewsC# check "null" or "Nan" or "false" or "0"
I’m having a validation difficulty. I have a View that sends to the Controller information, where in view is used knockoutjs, but there is time that he sends a null or "null" or "NaN" or "false" or…
-
3
votes1
answer192
viewsIs it bad practice to do a lot of things inside a builder? Why?
Is carrying out heavy processing, such as queries to a database or consuming an API, within class constructors considered a bad practice? Why? public class Classe { private String dados; public…
-
3
votes2
answers343
viewsMany to Many with Fluent API
I’m doing a mapping with Fluent API and I came up with a question on how I should do the mapping very much. For example, I have the classes below. public partial class Territories { public…
-
3
votes1
answer811
viewsHow to display 2 BD tables inside a Datagridview in the application?
I have an application developed C# using the project Windows Forms that displays the People Database Table in a list in the field DataGridView. However I need to show in DataGridView also the table…
-
3
votes2
answers95
viewsRecovers data with Request.Querystring
I have a Partial that loads the data: @using (Html.BeginForm("PesquisarEventoPorLocal", "CadastroEvento", FormMethod.Get)) { <div class="row"> <div class="col-sm-12 col-md-12"> <div…
-
3
votes1
answer171
viewsHow to do mathematical operations with a struct?
I have the following structure: public struct vetor { public float X, Y; public vetor(float X, float Y) { this.X = X; this.Y = Y; } } And this code: Vars.vetor _visao; Vars.vetor _recoil; //Os 2…
-
3
votes1
answer3537
viewsDynamic mapping error: Missing type map Configuration or Unsupported Mapping
I have a data dictionary something like this: public class Colunas { public string ColunaOrigem {get; set;} public string ColunaDestino {get; set;} public DbType Tipo {get; set;} } public class…
-
3
votes2
answers1193
viewsASP . NET MVC 5 - Dropdownlist with Modelstate?
I am developing a registration system using MVC5 with DAO, but there were some doubts that I could not resolve. I have a table where I register Projects and another one where the types of Projects…
-
3
votes1
answer115
viewsCodetemplate in . net core [scaffolding]
As in . net core 2.0 I do to create custom scaffolding templates? On the old system . net 4.6 copied the Codetemplates folder to the project. No . net core < 2 instavala o…
-
3
votes1
answer64
viewsI need help to transform this SQL into a LINQ
I have the following SQL: select conferencia.tb_conferencia.con_codigo, con_pedido, count(coi_codigo) as countItens, count(distinct cic_conferencia_item) as countItensConferidos from…
-
3
votes2
answers1164
viewsHow popular a select with Jquery
I have a registration screen where the user can add or not phone numbers. I am adding fields for entering the phone dynamically, but one of these fields is a select that will bring data from the…
-
3
votes2
answers4863
viewsReading XML in C#
I know there is a lot of Post on how to read a file XML, but I didn’t find any that present the XML with the same structure I have. I have the following Code. private void LeituraXML() { //Criando…
-
3
votes1
answer446
viewsProgressbar WPF
Hello, I saw several examples on the internet of progressiBar in WPF , but none works. It appears no longer fills the values, in fact it fills the values only after running the initial method where…
-
3
votes2
answers59
viewsHow to change the way a class/structure is printed?
I have the following structure: struct cores { int r, g, b; public cores(int r, int g, int b) { this.r = r; this.g = g; this.b = b; } } If I had a new structure printed, it would look like this:…
-
3
votes1
answer253
viewsHow to calculate days, ignoring the hours?
How can I calculate if spent 1 day ignoring the hours. Explaining, it would be more or less like this: I have a date 2017-09-09 11:45:20, normally it would have been a day when the 11:45 the other…
-
3
votes2
answers179
viewsWhy can’t I assign a list of a more specific type than the declared type?
I have this class example: public class User : APerson { private string _userName; [DataMember] public virtual string UserName { get { return _userName; } set { if (string.IsNullOrWhiteSpace(value))…
-
3
votes1
answer346
viewsHow to perform a Count in multiple columns?
I’d like to make a COUNT using LINQ / LAMBDA, but I’m having difficulties. Can help me? The idea is to reproduce the following query: SELECT Conta, Tipo, Documento, Nome, COUNT(0) AS Qtde FROM…
-
3
votes1
answer1037
viewsDoubt when deserializing JSON C#objects
I am deserializing the JSON below, and would like to know, if I need to create a class with all attributes related to this JSON, or can I just create with the attributes I need to use? Am I going…
-
3
votes2
answers626
viewsExecute a condition (if/Else) that is inside a string in c# 4.5
I own a class that generates files csv from a query, and that file may have several templates, some with conditions to display value x or y. These conditions are within a database and when I recover…
-
3
votes2
answers491
viewsDynamically provide buttons
insert the description of the image here.You can find out how I can through a textbox insert a numerical value, and with this value x make visible x buttons of y. ex. if I type 3 in the textbox, the…
-
3
votes3
answers948
viewsLogout com Identity
I am trying to use the logoff function offered by default in Identity: // POST: /Account/LogOff [HttpPost] [ValidateAntiForgeryToken] public ActionResult LogOff() {…
-
3
votes1
answer274
viewsUse of async with . NET Core and nhibernate
No. NET Core I know we have the async and await for request async. So far so good, but many frameworks in the market are creating methods with the signature MetodoAsync() and has the method without…
-
3
votes3
answers608
viewsLists repeating last added item
was studying about the lists in C# and I couldn’t understand what was wrong with my code (probably going to be very basic), all the items are the same as the last item added. I simplified the code…
-
3
votes4
answers1005
viewsConvert Int to bool
Guys, I need some help from you if (usr.Excluido = 0) { ModelState.AddModelError("", "Usuário bloqueado."); return View(model); } The deleted variable is as bool on my system, I am doing a login…
-
3
votes1
answer142
viewsHow to read the value of a readonly field?
I’m trying to read the value of a readonly field, but I’m not able to access its value, it doesn’t have the value in html only appears in the browser. <form id="form1" name="form1">…
-
3
votes1
answer1337
viewsHow to move and rotate where the mouse click is?
I created a script in which my character moves through click of mouse but there’s a problem: it’s not spinning in position Y, this is the condition I had to create for it to Rotacione on the axis X:…
-
3
votes2
answers67
viewsHow to avoid the sum of items in my lambda. Result is not expected
I got this lambda: [Route("getliberaitens/{id}")] public List<LiberacaoItensDTO> GetLibItems(double id) { var lista = contexto.Liberacoes .Join ( contexto.ItensLibs, t1 => t1.IdOrcamento,…
-
3
votes1
answer73
viewsAudio plays in editor, but not on mobile
I’m making a narrated game for Android in Unity 5 with c#, I use the following function to pick up the audio from Google’s voice. However it works only in the editor, when I have it installed on the…
-
3
votes1
answer989
viewsREINF - Invalid Signature
I’m developing a message for reinf but I’m having trouble sending the first event. By sending an R1000 I’m getting the message: MS0017 Invalid event signature. Invalid XML document Digital signature…
-
3
votes2
answers146
viewsError writing new record in Access database
I’m making a CRUD with Winforms in the C#, I have an error entering the date in the birth date field. This displays the following message when trying to save the new record: Missing operator syntax…
-
3
votes0
answers111
viewsThe Form gets stuck/Locked when I click the datetimepicker
I’m developing an application and I’ve done 90%, but I have a problem with the datetimepicker control. Normally its format is long, but I had to change to 'team' and enabled the ShowUpDown as true.…
-
3
votes1
answer26
viewsError running Updade-Database command
When executing the command Update-Database Package Manager Console gets the following error: Value cannot be null. Parameter name: entitySet I have only one model in the project for now public class…
c# asp.net-mvc entity-framework asp.net-web-api code-firstasked 6 years, 11 months ago Renan Carlos 1,594 -
3
votes3
answers569
viewsListbox - how to show full product name and bring up another column of values
I have this ListBox. When loaded he wears one txt file being like this: Code to load the ListBox: private void frmOrdemServico_Load(object sender, EventArgs e) { string[] d =…
-
3
votes1
answer98
viewsHow to Bulkcopy an excel file to an sql table
I wanted to make a bulkcopy from an excel file to an sql table. But you’re giving me this error when I try to send to sql: System.Invalidoperationexception: 'The Columnname indicated 'Transdate'…