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
votes2
answers92
viewsHow to make a function that takes two integer vectors and returns a boolean value?
I want to make a function that takes two integer vectors and returns a value Boolean, but when I put the: return (encontrou); It keeps error on the variable encontrou. Follows part of my function:…
-
3
votes0
answers44
viewsPick up on Mainactivity events in App.xaml.Cs
I have it on my App.xaml.Cs CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => { System.Diagnostics.Debug.WriteLine("Received"); }; When I receive messages, ie have…
-
3
votes1
answer48
viewsHow to create a filter with all products in the second list except with products that returned in the first list
Perform a filter with the products in the second list, except those that were brought in the first list List List<string> listaProduto = new List<string>(); listaProduto.Add("Arroz");…
-
3
votes1
answer148
viewsConvert Dynamic to query string
Is there any more "elegant" way to convert a dynamic for a query string? I’m currently doing with several Replace() but it’s not quite what I wanted. string data = new { email = email, password =…
-
3
votes0
answers603
viewsError when instantiating Context with Entity Framework
I’m taking the Entity Framework to learn, but when I run my code, it returns the following error: System.Typeloadexception: 'Inheritance security rules were violated by type:…
-
3
votes1
answer509
viewsTake values separated by spaces in C#?
I want to take the values, for example, 79 201 304 and store in one vector each number at one position. Example : int array[0] = 79; int array[1] = 201; int array[2] = 304; public static int…
-
3
votes3
answers92
viewsLinq C# with order
I have a LINQ query that lists the current month’s birthday: Ramal[] RamalAniver = (from a in db.Ramais where a.sAniversario.Contains(DiaAniversario + "/" + MesAniversario) && a.bAtivo ==…
-
3
votes1
answer58
viewsShow fields of an entity in a different View
I have an entity Academic who owns a Professor, I want in the View details of Academic the teacher responsible for it, i.e. Professor that belongs to that Academic. The code I’m already using is…
-
3
votes2
answers67
viewsRoute c# redirecting to wrong action
I have an action that returns a Partialview [HttpPost] public ActionResult SelectCidadesPorCodigoUF(int idUF) { //It do something and returns a PartialView } This action is mapped as follows:…
-
3
votes1
answer64
viewsConflict of reference Google.api
I have a reference conflict problem in the Google API. In my API classes I always rename as follows: SiteTeste.APIS.Google.<Servico>, where service is, Gmail, Translate, Drive or whatever.…
-
3
votes1
answer150
viewsTask is not called
Guys I have an api where your processing takes around 6 hours of execution, so I added a Task.Factory.Startnew with the main processing. So when someone calls, she responds to Statuscode 200 and…
-
3
votes1
answer179
viewsMigrations, Updating a null field to not null
I am updating the phone field and CPF of my User entity that was allowing nulls to not nulls. follow the migration file public partial class Required_fild_users_cpf_phone : DbMigration { public…
-
3
votes2
answers979
viewsHow to get value from a database column using C#
I have a web application that uses these 3 tables: Client: CREATE TABLE CLIENTE( ID_CLIENTE INT PRIMARY KEY, CLIENTE VARCHAR(50), ENDERECO VARCHAR(50), CIDADE VARCHAR(30), CEP VARCHAR(9), UF CHAR(2)…
-
3
votes1
answer323
viewsGroup items in application table Asp.net web MVC
How can I group items into a table? I am bringing these items from the database, I would like to group by the code of the same, for example, if there is repeated code 1 I would like to group it into…
-
3
votes1
answer400
viewsError accessing Automapper Createmap property 6.2.2
I’m practicing on a simple example I found on net on the subject. Only that I believe it is in an older version of AutoMapper and so I can’t access the property CreateMap when I call the class…
-
3
votes1
answer163
viewsHow to return string array of each book with its chapters and verses?
Follows code: var linha = string.Empty; List<List<String>> livros = new List<List<String>>(); string[] filesArray = new…
c#asked 6 years, 10 months ago Matheus Miranda 5,375 -
3
votes2
answers1387
viewsName of fields of a generic object - Reflection
Good morning, everyone. I have a problem that I believe can be solved with Reflection, but I do not know how to use and I hope you can help me in my difficulty. I have an object that will be passed…
-
3
votes2
answers155
viewsHow to make Where ands dynamically with Linq and Entity Framework?
How can I make the ands dynamically in the where using Linq and entityFramework? Thanks in advance for any help. return _dbContext.TbParceiro //Preciso fazer algo do tipo mas isso não funciona, não…
-
3
votes2
answers1207
viewsLeft Join with three or more lambda tables
I have the following consultation on SQL: select e.idEstado, e.txtNomeEstado, e.txtSiglaEstado, c.idCidade, c.txtNomeCidade, de.txtH1, de.txtTitulo, de.txtDescricaoEstado, de.txtDescription from…
-
3
votes1
answer142
viewsPerformance Itextsharp
I’m doing the reports using iTextsharp and the result has been acceptable, but working with many records has become slow. Currently I do so: I capture the database data (storing in a DataTable); In…
-
3
votes3
answers436
viewserror saving or updating with Entityframework
I have the following method: using (var context = new ClassContexto(ClassMaster.conexao())) { using (DbContextTransaction tran = context.Database.BeginTransaction(IsolationLevel.ReadCommitted)) {…
-
3
votes1
answer1644
viewsEntity Framework Core 2.0 - Add-Migration does not work
I am creating a new code-first project. When trying to create Migration, using the command [Add-Migration Initial -Context LogAuditoriaContext] it simply does nothing, creates nothing, makes no…
c# asp.net asp.net-core migrations entity-framework-coreasked 6 years, 9 months ago LeoFelipe 1,455 -
3
votes2
answers262
viewsHow to use Simpleinjector in a multi-layer project?
Imagine the classic architecture: Consoleapplication (Frontend) --> Business Layer (BLL) --> Data Access Layer (DAL) That is, Frontend references BLL that references DAL. See that Frontend…
c# software-architecture dependency-injection ioc simple-injectorasked 6 years, 9 months ago Ewerton 194 -
3
votes2
answers2574
viewsLINQ using function inside select new{} with lambda Expression
I am assembling a select, with the Entity Framework, which needs to "create a column" according to 4 criteria. I am trying this way: IQueryable<ImoveisDTO> Resultado = ctx.Imoveis.Select(ib…
-
3
votes1
answer161
viewsWhat name is given in C# when we use the expression "new {}"?
When I saw the use of expression new {} I remembered Javascript, where I use new Object and {} are equivalent. Just for study purposes, I made some comparisons, to see if Csharp followed the same…
-
3
votes2
answers655
viewsMysql parameter error with C#
string sql = @"UPDATE ivendas SET nritem=(@rank:=(@rank+1)) where id_venda = 20"; try { MySQLBase basemysql = new MySQLBase(); MySqlCommand cmd = basemysql.connection.CreateCommand();…
-
3
votes2
answers1405
viewsAdd a checkbox column to the datagridview
How to add a Checkbox column in Datagridview ? I need to do this for the user to select the Datagridview line with the Checkbox and then click the Save button. private void…
-
3
votes1
answer913
viewsSend Javascript by email
I have a code in C# that sends emails with HTML, until then ok, the problem is that I can not send scripts (JS). Yes, I understand why, must be security reasons. But there is no way burlar or do…
-
3
votes2
answers5957
viewsPrint HTML page keeping the page CSS
Good afternoon guys, I have a report that is generated on a page aspx with bootstrap and CSS. The content of the report is within a div <div id="pdf2htmldiv">...</div> where I call…
-
3
votes3
answers608
viewsRead a console line in C#
CS1503 Argument 1: cannot convert from "group of methods" to "Object" using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace…
-
3
votes1
answer568
viewsAccess a C# thread-based method object with Winforms
I created a thread to run a process that takes too long and makes the application process stop for a great while private void ExeConsultaClientes() { thread = new Thread(new…
-
3
votes1
answer100
viewsWhat precautions should I take when creating tables with 1:1 relationship?
Basically I’m in doubt about when I should use 1:1 relationship or a large table. In my case I would have the object public class Person(){ public Guid Id {get;set;} public string Name {get;set;}…
-
3
votes3
answers1166
viewsHow to access and stop a Thread? ASP.NET C#
I develop in ASP.NET MVC5 and within a Action of POST I start a Thread: [HttpPost] [AutorizacaoFilterAttribute] public ActionResult ProcessarEmails(ProcessEmailModel model) { ViewBag.Processing =…
c#asked 6 years, 6 months ago Leonardo Bonetti 5,313 -
3
votes2
answers1242
viewsget return from sql c#
I need to get the return of one select that comes from a procedure. I saw about using the ExecuteReader, but I’m not getting the data that’s coming in. To procedure is fine As the return of…
-
3
votes1
answer94
viewsHow to find out if TCP Listener is listening?
Library that I use: https://github.com/rdavisau/sockets-for-pcl Follows code: await client.ConnectAsync(address, port); The code above is the client and works normal. Let’s say the server is off,…
-
3
votes1
answer12121
viewsPostasync Json C#
I have the Following class set: public class Ticket { public string name public string content public int itilcategories_id } And the following code sample: static HttpClient client = new…
-
3
votes2
answers106
viewsHow to implement an interface to secure a specific contract?
Need to get an interface to implement a list of a certain type: public class ITrade<T> { public int date { get; set; } public double price { get; set; } public double amount { get; set; }…
-
3
votes0
answers1472
viewsSystem.Threading.Threadabortexception: Thread was being undone. While consuming webservice operation
I have the following code: proxy_hom_recepcionarLoteRps.RecepcionarLoteRPS proxy = new proxy_hom_recepcionarLoteRps.RecepcionarLoteRPS(); proxy.Url = url + "/arecepcionarloterps"; string resp =…
-
3
votes2
answers1248
viewsC# XML digital signature, poorly formed Reference element
I have a code c# that generates a xml with digital signature, but when calling the function signedXml.ComputeSignature() it shows the following error: Badly formed Reference element. However, I…
-
3
votes3
answers8240
viewsFill string with zeros
How to check and fill in a string if its size is less than one condition? For example, I always need to have a string in the size of 8 or 9. If the string is longer I give a substring taking only…
-
3
votes1
answer144
viewsEncrypting a string with SHA1 does not return the expected value
I’m consuming a webservice of nfse (electronic service invoice), and the nfse batch receipt function, there is that the password is encrypted using the algorithm SHA1. The Handbook exemplifies this:…
c#asked 6 years, 5 months ago Rodrigo K.B 637 -
3
votes1
answer478
viewsConverting Java code to C#
I would like a help to convert the following code in Java to C#. public static long convertStringToBitboard(String Binary) { if (Binary.charAt(0)=='0') { return Long.parseLong(Binary, 2); } else {…
-
3
votes2
answers76
viewsFailed to display Address class fields when using object creation method expressed in C#
Visual Studio 2017 suggested something that I was surprised, the creation of object without using the new operator, I was surprised, because I’m coming from Java and it’s been a year since I stopped…
-
3
votes1
answer183
viewsDifficulty in picking up a certain type of return in c#
I have a return that I send via Ajax that it returns in the URL as follows:…
-
3
votes1
answer496
viewsRequest arrives null on C#
I have a request that’s being made this way at angle 5. enviarEmail(titulo: TitulosCobranca, unidade: UnidadeEmpresa) { let param: any = { titulo: titulo, unidade: unidade } return…
-
3
votes3
answers900
viewshow to find a string for json
I have a string in json format. In this way: {"IdLead":4186960,"Concessionaria":"Mila - Centro","DadosQualificacao":{"IdEvento":79654,"Qualificacao":1,"Motivo":6,"DescricaoMotivo":"motivo…
-
3
votes2
answers784
viewsVowel in full name C#
I need some help, I’m doing an exercise, to verify the existence of how many vowels 'a' has in a name, but my debug, points the vector always with the character ' 0', I’m trying to insert Length…
c#asked 6 years, 4 months ago Leandro Azevedo 303 -
3
votes1
answer1250
viewsIdentify selected item Listview
I have a ListView that loads values from my database. I would like to know how to identify the selected item so I can recover the value of the field CODIGO_PRODUTO and make a UPDATE/DELETE in the…
c#asked 6 years, 4 months ago Giovani Rodrigo 299 -
3
votes1
answer71
viewsCookie returning duplicate value
I am cookie saving an object in JSON format. In the properties of this object I have links with several parameters. With each link change, I update the cookie with the new value. Example of the…
-
3
votes3
answers666
viewsASP.NET - How to use multiple post methods in the same controller?
I have the following problem: On a given HTML page I have two buttons that call different POST methods in the same controller. @using (Html.BeginForm("UserInfo1", "UserInfo", FormMethod.Post)) {…