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
answer574
viewsVoice recognition without Grammar
I have an example of using the Microsoft Speech Api, but all examples of Speech Recognition use Grammar for recognition only of what was pre-defined, I wonder if I always have to use Grammars or if…
-
2
votes1
answer293
viewsHow to map the results of a previous store to an entity using Entity Framework?
Personal talk. I’m doing a project with MVC 4 and EF6. I’d like to call in a proc and her results populate an entity. But my entity is not a bank table, so I did not use Dbset on it. What happens is…
-
2
votes1
answer9195
viewshttpclient - Webexception: The underlying connection was closed: The connection was closed unexpectedly
I created a very simple C# console application to test connection in an API, but I can’t submit the request. I tried with other Apis and they worked, but this particular one I can’t. It would be a…
-
2
votes1
answer308
viewsGeneric Method for REST Query
I need to refactor this method to make it work better. This method works perfectly when calling on an external API Rest returns list. However, it gives exception when the return object of the…
-
2
votes1
answer87
viewsReturning two objects from the Repository
My application is divided as follows: Repository --> Access Progress database Controller --> Receives Repository return and sends to View View --> Receives Controller Return. Next, my…
c#asked 7 years, 3 months ago Anderson Apdo de Souza 151 -
2
votes1
answer199
viewsSending shortened date does not work abbreviated Asp.net mvc
I am creating a form in ASP.NET MVC and, creating the field "Datamessage", I initially put Textbox to load a date with the month in full, as below: Image of the form with the field "Date of the…
-
2
votes2
answers373
viewsInheritance in Entity Framework
I have the following structure: Table: Services (Services table) - with the common properties of all services + Type + Serviceid Table: Service 1 (Service table 1) - with service properties 1 Table:…
-
2
votes1
answer75
viewsI want to search information of a table with EF
I have the following form code: @model Domain.Entities.Tabela1 @using WebUI.HtmlHelpers @using WebUI.Extensions @{ ViewBag.Title = "Tabela"; Layout = "~/Views/Shared/_Master.cshtml"; } <article…
-
2
votes1
answer55
viewsC# - Use form data in IF
I am trying to recover data from the form and need to use them in an IF. protected void btnSubmit_Click(object sender, EventArgs e) { try { if (txtLocalizacao.Text != "") { conn.Open(); SqlCommand…
-
2
votes1
answer216
viewsC#: how to identify sheet title
Good morning guys, I’m making an excel converter to txt and a doubt arose, I was trying to make an algorithm in which it detects the column title and returns error if the column had the same title,…
-
2
votes1
answer403
viewsAsync method returning a List<string> how to use?
I have a method called consulta_usuario_email, that is responsible for searching in the table of registered users, the emails of users of a certain department: public async…
-
2
votes0
answers283
viewsCreate an ellipse / circle in Unity + C# - using Point3d and Virtualdraw
I need to implement a Unity project, creating an ellipse. In the project there is already the code of creation of "line" and "rectangle" that works perfectly. The project is for a master’s degree…
-
2
votes1
answer118
viewsHow to put € symbol on Datagridview
I have a Datagridview with numerical values and some of them represent monetary values, but from the database comes only the number and wanted to put the currency symbol in front of the value. This…
-
2
votes2
answers475
viewsUntreated exception (index based on 0)
My idea is to make a small registration and I’m testing this to later add this data in a BD. The problem occurs on the line Console.Write("\nGenero do disco : {1}", genero);, at the time of…
-
2
votes2
answers3402
viewsError: Not all code paths return a value
Follow the error: "Logincliente(string, string)":not all source paths return a value class Conta { #region atributos public String nomeCliente { get; set; } public String numAgencia { get; set; }…
-
2
votes1
answer141
viewsProtect Excel spreadsheet in C#
In a C#application, you can have from 1 to 2100 hours of data collection. Data is saved in a CSV Excel spreadsheet every minute. With the code below we can hide and show the file. #region string…
-
2
votes1
answer1152
viewsSending complex objects via Httpget
I have a search method in my Webapi, as it is a search, I used [HttpGet], as a parameter of this method, I pass an object with the filter options I want, for example: public class ParametrosBusca {…
-
2
votes2
answers1028
viewsHow to query containing MAX and COUNT via LINQ
I got the following model: public class Crm_Analise { [Key] public int id { get; set; } public string cod_item_CRM { get; set; } public string TAG { get; set; } public string data_creat { get; set;…
-
2
votes1
answer676
viewsIncorrect mime for XLS files
I am doing a migration of a particular system written in ASP.NET (site) and in a certain part of that system there is a place where you upload a file XLS. There is a check against the mime type of…
-
2
votes2
answers554
viewsWhere to place a non-entity object in the DDD
My ASP.NET MVC project in C# has a Domain layer where I have entities, and business rules. I need to add a new rule where I should return an object with an internal list, but I ended up having a…
-
2
votes1
answer272
viewsIs it correct to use List with Viewmodel?
I own the ViewModel down below: public class Crm_AnaliseViewModel { public string TAG { get; set; } public int ATUALIZACAO { get; set; } public string RELATORIOS { get; set; } } Then in the…
-
2
votes1
answer114
viewsForm Zera values greater than 999.99
I’m going through a problem I’ve never seen before. I’m hoping someone has seen it and can help me. I’m working with Asp.net mvc 5, and sending a form via post to my controller. My model: <div…
-
2
votes2
answers165
viewsCan’t find Parameter passed to the Insert command
I am developing a web application in ASP.NET and I want to insert data in a table in the database, but when specifying the parameter shows the following error in the…
-
2
votes1
answer360
viewsHow to put the background color in the first line cells using NPOI?
I am using the NPOI library to generate an Excel file. It is the first time I am having contact with this library and would like help to put background color in the cells of the first line. My…
-
2
votes1
answer209
viewshttppostedfilebase always empty when switching to controller
I am sending a form to my Controller passing one HttpPostedFileBase as parameter. The problem is that it always comes empty. HTML: <form action="@Url.Action("Import","Importacao")" method="post"…
-
2
votes1
answer397
viewsXml Treatment with ASPNET MVC Core?
I’m working on uploading Xml using the ASPNET MVC Core, I get in the controller the file this way: public async Task<IActionResult> Upload(IFormFile param) { } but I need to check it before I…
-
2
votes1
answer337
viewsError when connecting to Sqlserver C# Web.config database
I’m trying to make an application .NET MVC, but when I connect to the bank is giving the following error: An Exception of type 'System.Nullreferenceexception' occurred in Gerarxml.dll but was not…
-
2
votes1
answer3085
viewsGrab a list from the View and move to the controller c#
I have 2 lists that come from the database, one from technical and another from suppliers. I’m not able to take the View and pass to the Controller. And how to receive this list in the controller…
-
2
votes3
answers330
viewsListbox selection
Every time I move an item up or down a listBox he loses focus of the item. I’m not always able to focus on the item. For example, let’s assume my list has 200 items. Then I want to move the item…
-
2
votes2
answers48
viewsSelection of chekbox in datagridview
Good afternoon. I have a datagridview that I populate through a database select, and in this datagrideviwer I have a column with a chekbox, to select the line I want to send to the print, but the…
c#asked 7 years, 2 months ago Junior Guerreiro 617 -
2
votes2
answers1884
viewsWhat are model and model variables for in a View?
What are variables for @model and Model in a view? In my view I use it at the beginning of the code: @using Html5DataList.Models @model List<Estabelecimento> And to access the data, I use it…
-
2
votes1
answer111
viewsError when performing LINQ query with equals in Where enclosure
When executing the query below: public ActionResult GridViewPartial() { if (Session["cod_cli"] != null) { int cod_cli = Convert.ToInt32(Session["cod_cli"]); //var model = db.DadosTecnicos; var model…
-
2
votes1
answer82
viewsIs there equivalent to VB.NET Call in C#?
The question is simple. There is a keyword equivalent to Call of Visual Basic.NET in C#? In Visual Basic, I called a class method without having to declare a member explicitly to it: Call New Form()…
-
2
votes2
answers262
viewsDropdownlistfor selected values do not persist
I am using Asp.net C# with mvc 4 and in my View I have a Dropdownlistfor, with a class I used of bootstrap-multiselect, as in the image: And the code in the view: @Html.DropDownListFor(m =>…
-
2
votes1
answer1609
viewsSet the download location and name of each downloaded file - Selenium Webdriver C #
I’m doing an automation using Selenium with Chrome Webdriver. The application has to make a series of downloads that need to be saved with different names (Report Date + Type) and in folders that…
-
2
votes1
answer464
viewsError returns when trying to start some threads in a list
I need to create a function for my program, which when the user is pressing the NUMPAD_8, he shut down all the thread, and if he squeezes again, he turns them back on. How I’m creating the thread…
-
2
votes1
answer2607
viewsChange existing column to Identity
Having an entity where the first key is an integer and the same is defined not to be an Identity public class Teste { [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get;…
-
2
votes2
answers1516
viewsDeserialize json string array to string array
Hello, I’m having trouble deserializar a Json, I’m not getting the right data. There is the Main Class that would receive the data list public class PermissaoDossie { [JsonProperty(PropertyName =…
-
2
votes1
answer269
viewsError starting WPF application
When starting my application, an error message is displayed. The problem is that I cannot locate the source of the problem. Before I couldn’t, it started today. I thought it might be some…
-
2
votes2
answers1697
viewsDate range C#
I have a table in the bank called Quota, this quota has two columns one for data_start and data_end, so far so good, now I have another table called Order that also has data_start and data_end,…
-
2
votes1
answer485
viewsConversion from Enum to string
Good afternoon! I have the following situation, as return of a request I receive a json with various information. In c# convert this information to objects using Jsonconvert.Deserialize().. Look at…
-
2
votes1
answer398
viewsLoading reportviewer through an object
I am using Report Viewer to do some reports, but I am not able to access some data from my object. instead of making a direct connection to the database I pass a Datatable as a reference, and in…
-
2
votes2
answers82
viewsFilling Label with Linq using Tolist()?
I have a table with the following schematics: GarantiaImovel | imovelID | GarantiasTipos 12 | 3 | Caução2 12 | 4 | Depósito 12 | 5 | Caução2 12 | 5 | Fiador 12 | 5 | Seguro Fiança So I have the…
-
2
votes1
answer51
viewsForm running after closed
I have an app with a Form1, where is my pictureBox. I added another Form2 to the project that when executing it it becomes a magnifying lens, thus, you can use on top of the first Form1. My problem…
-
2
votes1
answer42
viewsCosmosdb Bind in Azure Functions Local
How to bind Azure Cosmodb to Visual Studio in Azure Functions? Note the code below, the inputDocument parameter would be the Cosmosdb Bind. When we create Funcão direct in the Azure portal, it…
-
2
votes3
answers86
viewsWhy do you print the variable type instead of the result?
See the method below: public void TesteLambda() { List<String> selecoes = new List<string>(); selecoes.Add("USA"); selecoes.Add("Brasil"); selecoes.Add("Itália"); selecoes.Add("França");…
-
2
votes0
answers118
viewsSql Server in C# using Bindingsource
I am on a project where I have a sale screen. When making a sale, a method checks if the customer has an account. If he doesn’t have one, he creates one for himself, so far so good. But if the…
c#asked 7 years, 1 month ago natanfoleto 57 -
2
votes2
answers751
viewsEntityframework - new table not created
Following this tutorial the tables were created all right. Then I took a test, created a new entity, did the update-database and no creating the table in SQL Server 2012. I made some changes to the…
-
2
votes1
answer59
viewsIt is possible to know in which Routes. Map() the call of an Action fell? ASP.NET MVC5
Afterward of that question I was wondering, is it possible to know on which route map my Action used? Example: I have two routes.MapRoute() routes.MapRoute( "Home", "Image/{id}", new { controller =…
-
2
votes1
answer160
viewsASP.NET route does not receive the parameter in Action after being set
I Mapeed a new route on my site like this: routes.MapRoute( "PaymentEdit", "Payment/{type}", new { controller = "Contributor", action = "Payment" }, new { type = UrlParameter.Optional } ); My Action…