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
-
0
votes1
answer496
viewsCreating folders within Program Files
I’m having trouble creating folders within program files. Where I work there is an application that only works if the files are inside program files and the process of creating the folders today is…
c#asked 7 years, 4 months ago Fabio Aragão 135 -
0
votes1
answer964
viewsc# Take text and insert on top of image
I have a pictureBox, and I need the user to be able to make "markings" on the image. For example, the image is a human body, I need the user to click on the photo where the arm is, for example, a…
-
0
votes0
answers46
viewsWhat is the most efficient way to place objects within a list contained in another object?
public turma(string nomeTurma) { this.nomeTurma = nomeTurma; listaAlunos = new List<aluno>(); } public aluno(string nomeAluno, string dataDeNascimento, string nomeTurma) { this.nomeAluno =…
c#asked 7 years, 3 months ago Amadeu Antunes 3,331 -
0
votes1
answer1397
viewsDoes not insert lines in Datagridview
I make a select in my database and it brings the values in the datagrid. However when I try to add/delete lines, it gives error: It is not possible to add lines programmatically to the Datagridview…
-
0
votes2
answers368
viewsC# and Sql Server, inserting with proc using BEGIN TRAN
Good night! I am entering a record using the C# and Windows Forms, I am using a proc that inserts in two tables at once, the code is working, but, I created a rule that the store can only have only…
-
0
votes3
answers58
viewsNullreferenceexception error in Join
I created a Join in LINQ to create a List: (from p in listaProcedimento join pd in oListaprocedimentodetalhe on p.codigo equals pd.codigoProcedimento into pd1 from pd2 in pd1.DefaultIfEmpty() select…
-
0
votes0
answers183
viewsConnection to slow database
I have a program in C# that when I start and ask to show me the data entered in Sql Server takes time to open, but after this time is already faster. There’s a way for the first time to be faster?…
-
0
votes1
answer60
viewsGeneric method for locating a specific value in several types of similar structures
public enum EXEMPLOENUMERADOR1 { blablabla1, blablabla2 } public enum EXEMPLOENUMERADOR2 { blablabla3, blablabla4, blablabla5} public enum EXEMPLOENUMERADOR3 { blablabla6, blablabla7, blablabla8,…
-
0
votes0
answers131
viewsType is defined in a meeting that is not referenced
I have a project called DataLibrary, a . dll is referenced in another project of mine, but for some reason, when compiling VS gives me an error to say that there is a type that is closed in…
-
0
votes1
answer146
viewshow to count records of an ini file in C#?
Como contar Registros de um Aqruivo.ini e usa-las em loop for (int i = 0; i < 15; i++) { Exemplo: no [bot] tenho 5 elementos cadastrados ! ao invez de ser 15 adicionado manualmente ao for eu…
-
0
votes1
answer1933
viewsHow to handle the Object reference error not set for an object instance
Create 2 new columns in my table dbo.FormaPgto - FPNFCeCpnjCred and FPBandeira both Allow Null When I consult a payment method, give the following error in the fields txtFPCnpj.Text =…
c#asked 7 years, 3 months ago Igor Carreiro 1,917 -
0
votes1
answer41
viewsuse WCF service method returns The Caller was not authenticated by the service
I have a project with several WCF services compiled, and accessible by another project on the same machine. Now I’m trying to connect to one of these services from another machine. I put the service…
-
0
votes3
answers1868
viewsMask in table values
I am looking for a way to create "Masks" for the values of my table in ASP.NET. Currently, I am displaying the values like this: @model TB_RESUMO_GERAL List<TB_RESUMO_GERAL> rg =…
-
0
votes2
answers111
views -
0
votes1
answer589
viewsSession Timeout MVC 5
I’m trying to implement Timeout Session in an MVC5 application. I have the following string on Web.config: <sessionState mode="InProc" cookieless="true" timeout="15" /> I created the class :…
-
0
votes1
answer178
viewsForce a Sqldatareader result
I have the following method: public ClassCardapio MontaCardapioEdit(string periodo, int tipo) { ClassCardapio cardapio = new ClassCardapio(_stringconexao); _conexao.Open(); var sql = $"SELECT " +…
-
0
votes2
answers2083
viewsRemove infobar from Chrome when running tests with automated software
I tried to implement the Chrome Options in my script to delete that yellow bar of Chrome information, which is displayed every time we are running automated tests ("Chrome is being Controlled by…
-
0
votes1
answer633
viewshow to read a result Json from google Directions API
I’m getting this json from google Directions API https://maps.googleapis.com/maps/apidirections/json?origin=-22.8895625,-47.0714089&Destination=-22.892376,-47.027553&key= I need to read it…
-
0
votes1
answer89
viewsDeclare textbox event in XAML
How do I declare the Keypresseventargs event from a textbox to work with this event in Code Behind? The code to run the event I have, I just can’t declare the event, as I do with Click, for example.…
-
0
votes1
answer46
viewsMapping 1 to 0, 0 to 1
I need to create a map between two existing entities, where both are independent. So. I have an entity DepositoTransferencia and the other is Conta. The idea is that at a given time, the entity…
-
0
votes1
answer215
viewsWPF C# datagrid create multiple column header
I’m dynamically creating columns for a datagrid, but I need to create headers as below, some hint on how to do using c#? --------------------------------------------- | Person 1 | Person 2 | |…
-
0
votes0
answers82
viewsMetroframework - scrollbar only style after click event
Good guys, there is a bug in the layout that when I load the Grid, the scrollbar (horizonal and/ or vertical) is not stylized until after some click event. For example: Scrollbar before the event:…
-
0
votes0
answers142
viewsControl X-axis markings in date data charts
I have records in the database and a graph where I can visualize them. The graph is of data x voltage in volts. When I have few records in the table the chart shows exactly the date recorded in the…
-
0
votes2
answers44
viewsPersistent error in C# database
I was doing a project but there was a problem involving Oledbcommand occurring in two different places: dr_alu = _dataCommand.ExecuteReader(); if (dr_alu.HasRows == true) dr_reg_notas =…
-
0
votes0
answers137
viewsLINQ Dynamic from DTO - Datetime Filtration
I’m trying to assemble a dynamic filter from a Dtofiltro object that I get filled through the View. My problem is, when I try to filter the results that will be shown on the screen by Mesano, I…
-
0
votes1
answer251
viewsLoad list with Entity
The following. I created a context class inherited from DbContext. public class SiloContext : DbContext { public SiloContext() : base("inetConn") { } public DbSet<Produto> Produtos { get; set;…
-
0
votes1
answer661
viewsCannot implicitly Convert type error
I’m having a mistake CS0029, Cannot implicitly Convert type int' toUnityengine.UI.Slider' How can I fix it? First Code: using System.Collections; using System.Collections.Generic; using UnityEngine;…
-
0
votes1
answer171
viewsc# Move image without trace
I’m moving one picturebox over another with a mouse. But she keeps leaving a trail behind when I move the mouse, the trail disappears right away, but there’s a way to remove it? I tried to take the…
-
0
votes0
answers182
viewsInsert given with Entity and no Identity field
I have this method to insert in the bank: public virtual void Inserir(T item) { contexto.Set<T>().Add(item); contexto.SaveChanges(); } And I have it in my Product entity, for example: .......…
-
0
votes3
answers136
viewsProblems with result accuracy
I’m having a problem where I did a program to calculate a student’s average, where the condition is: MEAN = NOTA1 + NOTA2/2 (the result should be >= 7 for the student to pass) The program is…
c#asked 7 years, 3 months ago Luciano Brandão 21 -
0
votes0
answers55
views -
0
votes1
answer665
viewsAsp.net c# DDD - problem when passing data from Entity to Viewmodel
I am developing an ASP.NET MVC project, with DDD structure and using Simple Injector. I can perform BD persistence normally, however, when retrieving information and displaying it in a list, it…
-
0
votes1
answer41
viewsDifferent layout on the last datagrid line
I have a datagrid where I show values referring to the beginning and end of a period. For this, I created the columntemplate down with 2 textblocks, but in the last line, I show a value that is the…
-
0
votes2
answers271
viewsCheck if file exists for 20 seconds C#
I’m making a module that works with file exchange and the documentation asks to wait 20 seconds for the status file xxxxxxxx.However, I do not know how to implement this in C#. I was trying…
-
0
votes1
answer344
viewsSame partial view within multiple modal popup
I have a content that is inside a partial view. There are situations where I need to open popup’s that change only buttons and their actions. But the content is always the same as the partial view.…
-
0
votes1
answer209
viewsSave Canvas as Image - UWP
In applying UWP, I have the following canvas <Canvas Name="Banner" Width="500" Background="Black" Height="200" Margin="334,53,-711,-156"> <Image x:Name="img_Fita" HorizontalAlignment="Left"…
-
0
votes1
answer61
viewsMethod [Test] not found after build
When I do the build from the script below, does not return any error; however, build does not locate the test method [Test], and I can’t execute it. My script is object oriented: calls the class…
-
0
votes1
answer51
viewsView error returning a txt file
I’m using the following code in my Controller: public ActionResult geraBpa() { var caminho = System.Web.HttpContext.Current.Server.MapPath("~/Content"); StreamWriter file = new…
-
0
votes0
answers50
viewsIs there a difference in performance between returning an image in the Controller or in the View?
I just learned how to search and display an image from the database. I managed to do it two ways: First: Through an Actionresult in my Controller: public ActionResult RetornaImagemDoBanco(int id) {…
-
0
votes1
answer27
viewsIdentifier on grid lines
They could tell me if there is any simple property or way to put an identifier in the grid lines but without being the ID in the table, for example I have 5 records with id 32,45,99,100e and 200.…
-
0
votes1
answer178
viewsWPF C# Outlook Mailitem insert image in email body
I am using the code below and can insert an image into the body of the email. How would you add more images? Is it necessary to create multiple "imageCid"? The code below only shows the last image.…
-
0
votes2
answers593
viewsHow to model the products table for an e-commerce?
I have a question about how to model the table Produto of a small e-commerce I’m doing. I have been seeing some e-commerces and came across the following situation: mm same product can have…
-
0
votes1
answer317
viewsCalculation of currency sum
I need a help to make a calculation actually a sum per coin, as shown in the image below: follows my code. private void ListaGrid() { conex.Open(); string strSQL = @"SELECT DISTINCT SY.YF_DESC_SI AS…
c#asked 7 years, 3 months ago Junior Guerreiro 617 -
0
votes1
answer213
viewsRun Modal Open Screen Script in Ajax. C#
Problem: I’m in the Index view, it has a button that opens the Create view on a modal screen, on this modal screen I want to run a javascript code, but for some reason it is not running. I am…
-
0
votes3
answers335
viewsAdd data from a sql column c#
My problem is this: I need to sum up the total hours of the employee who are in the bank, already in a separate column. Just to be clear, the hours the employee worked the day are already ready, I…
-
0
votes0
answers55
viewsCannot implicitly Convert type
I am in error in instantiating the service. It is generic and I need it so, because I can use any entity in it. When I start the service in Hibernate, I need to pass the entity I will work to use…
c#asked 7 years, 3 months ago Eric Martins 1 -
0
votes0
answers108
viewsError making POST from a json to a Web API
It’s giving me an error when I try to make a POST to the API that error is: System.Net.Webexception: Remote server returned an error: (405) Method not allowed. The code I’m using is: var…
-
0
votes1
answer91
viewsUsing another path to pull files from a folder outside Directoryinfo
My project is running perfectly, but I’d like to replace that path DirectoryInfo to another who pulls himself straight from the folder without using my directory. Code: public List<Arquivos>…
-
0
votes1
answer172
viewsCreate a command-only class
I created a class only of commands, so far so good, I pulled the class of commands to the main class but I’m with a mistake Command class: public bool OnCommand(string[] args) { if (args.Length >…
c#asked 7 years, 2 months ago Leonardo Araujo 55 -
0
votes1
answer236
viewsLambda or Linq brings me all the fields and not only those of expression
Just for learning even, understand the section. I did a lambda of a bank with only 6 fields, like this: public List<LiberacaoDTO> getAutoriza(int idorcamento) { var lista = contexto.Liberacoes…