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
answer69
viewsMahapps - Change icons to a desired PNG format
I found a really cool web WPF project. It uses a framework called Mahapps. In the Hamburger menu there are some icons that use images from a package of Mahapps itself. I wonder if there is a…
-
1
votes1
answer290
viewsHow to do a search in c#?
I’m having some difficulty doing a search as the image illustrates Using combobox worked, here’s the code Class public void pesquisar(int ID) { Artigo List = new Artigo(); SqlConnection conexao =…
c#asked 7 years, 5 months ago António Mateta 159 -
1
votes1
answer237
viewsFK error while running Migrations on C#
I have the following scenario public class branch() { public Branch() { Branchs = new HashSet<Branch>(); } [StringLength(80)] public string Description { get; set; } [Required]…
-
1
votes1
answer285
viewsMigrating from Webforms to MVC, what is the best way to store and manipulate a logged-in user’s data?
For years I worked with c# systems in Webforms, however, by necessity I migrated my development goal to mobile applications with Xamarin and standards MVVM. Now in parallel I am developing again WEB…
-
1
votes2
answers901
viewsHow not to allow the user to access the previous login/registration page after logging in or registering
I am developing an ASP.NET application and when the user logs in and clicks on the browser button to go back he can access the login/registration page, even if I check the logged-in user’s key on…
-
1
votes2
answers180
viewsASP.net Javascript does not recognize Textarea if it has a runat="server" tag
I have a problem with my Javascript. I am using a server code to do the numbering in a Textarea when the user gives Enter, however, if that TextArea has the tag runat="server" Javascript does not…
-
1
votes3
answers314
viewsJquery function does not find the Controller when I go up to the server
During development the function below finds the Control and makes the request correctly, but after publishing on the server the function no longer finds the Controller: During the development I have…
-
1
votes0
answers462
viewsHow can I use two models in the same view?
I have a View that has a dropdownlist and a text box. This dropdownlist is returning your items from a model. After filling these two objects, I make a request that will bring some results that I…
-
1
votes1
answer52
viewsHow to return warning in a View if there is no data to display?
I created the code below that generates a list. It checks whether the list contains any data saved in it or not. If you have data, returns a View with the list inside, if you have no data, returns…
-
1
votes1
answer780
viewsHttpwebrequest C#error
I am making a request in a URL and trying to get the answer, I get the following error: The underlying connection was closed: Unexpected error in an upload. The point is that this instruction worked…
-
1
votes1
answer120
viewsError inserting data with Entrityframework C#
I have a very strange problem, I have 3 tables, being them, Countries, States and Cities, all of them are configured certainly equal, but it is giving error only when it is inserted data in the…
-
1
votes1
answer36
viewsError in constructor name parameter Objectparameter C#
When I pass a string variable to the Objetparameter parameter of the following error. string nomeParameter = sql.Substring(startPosition, stopPosition - startPosition); ObjectParameter parameter =…
-
1
votes1
answer172
viewsPerform database mapping for Dbset<T>. Sqlquery()
Error while running Sqlquery on my Dbset. There is no mapping of the object type System.Data.Entity.Core.Objects.Objectparameter for a native type managed provider. I would like to leave my database…
-
1
votes0
answers62
viewsError while deleting line in Gridview ASP.NET C#
I have the following GridView: If I delete a line from Grid and try to save, it returns the following error Input string was not in a correct format. This error occurs as soon as it enters the…
-
1
votes1
answer103
viewsInput Entityframework C#
I have 3 Entity, where are Countries, States and Cities. I am performing the Crud of the City Entity, and saving is asking for the relationship of States and Countries, but this I do not need,…
-
1
votes1
answer2356
viewsThe percentage returns me zero in c#
When the results are printed, the percentage of men and women interviewed and people with income up to 500 kingdoms equals zero. `string nome; char sexo, estado_civil; int idade, cont = 0, cont_m =…
-
1
votes0
answers41
viewsGenerate grid with multiple records
Good morning, I need to do a grid where I need to say exactly the value of each row of it based on a column of a table in the bank, I need help because I have never done something like this. It is…
-
1
votes0
answers55
viewsUpdate rate Limits at Runtime using Webapithrottle is not working
I have a Webapi in ASP.NET MVC and I need to control the access limit, in addition, I need to change the limits values at runtime. I implemented as this example on the site Webapithrottle (section…
-
1
votes1
answer100
viewsIcollection in Put Webapi method
I have the Put method in a Webapi Rest service // PUT: api/pessoas/5 [ResponseType(typeof(void))] public IHttpActionResult Putpessoa(int id, pessoa pessoa) { if (!ModelState.IsValid) { return…
-
1
votes1
answer480
viewsGet error message in Httpclient Post
I have a WCF Service on a server whose service is also configured as Webinvoke: [WebInvoke( Method = "POST", UriTemplate = "/work", BodyStyle = WebMessageBodyStyle.WrappedResponse, ResponseFormat =…
-
1
votes1
answer305
viewsParameters named in - Asp.net url
I have a problem with automatic url generation next to Asp.NET I have the following code: [RoutePrefix("c")] [Route("{action=Index}")] public class ConteudoController : BaseController {…
-
1
votes1
answer598
viewsPath to the Webapi URL
I have a Webapi Rest service, I managed the controllers by the wizard that defined the answers in "api/{controller}/{id}", such as get by id: // GET: api/pessoas/5 [ResponseType(typeof(pessoa))]…
-
1
votes3
answers160
viewsProblem mapping entities related to Fluent API
I am starting with EF and I am having problems to map the relationship between my entities. 1. Entities There are two entities in the project that I am using to practice the subject. They are: User…
-
1
votes1
answer371
viewsHow to encrypt data in App.config
I would like to encrypt the Keys (Apikey and Secret) below in App.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0"…
-
1
votes1
answer499
viewsIt cannot be assigned as it is read-only after doing a "Join"
Controller: [HttpPost] public ActionResult Listar_Json() { var id = 5; var search = Request["search[value]"]; //Aqui pega valor digitado no input, digamos que ele digitou 100.000,01 var query =…
-
1
votes0
answers44
viewsDSL Tools: Centralize an Shape in the diagram
I’m developing a DSL. In the main window, I have two panels (Panel): in a, a list (listbox) of shapes of the diagram, and in the other, the diagram itself. I would like, by clicking on an item in…
-
1
votes0
answers244
viewsValidateantiforgerytoken + Back button
Good morning. I have a login form on a web page using MVC 5, I am using the [Validateantiforgerytoken] function to validate the forms for security reasons. The page logs in correctly, but when you…
-
1
votes1
answer737
viewsSend email to multiple recipients
I have a class to send email, which works perfectly for only one recipient, but I need to send it to several people, I made a select that searches the necessary emails and puts the ";". But when I…
-
1
votes1
answer398
viewsHow to cancel the execution of a function in C#
I am developing a C# WPF desktop application in which there is a function responsible for sending email EnviarEmail(), when this function is executed it takes a certain period of time for it to be…
-
1
votes0
answers49
viewsQuestions about continuation in C# studies and suggestions to get an internship
Hello, I’m in 2° SI course period, but I’ve been studying C# on my own through the Caleum: C# and Object Orientation booklet. I’m really enjoying the language and I intend to go deeper into the…
-
1
votes1
answer438
viewsC# Calling an object from a string
I wonder if there’s a way to call an object from a string. Here is an example: public class Butao { public string _Name_; public float _Price_; public Butao(string name, float price) { _Name_ =…
-
1
votes1
answer58
viewsList is being filled in but the properties are null
Hello, I am using the following method in C# : public ActionResult Gravar(int pCodigo, string pDestino, int pRespDestino, int pOs, int pProjeto, string pEstabelecimento, string pObs, int pPim,…
-
1
votes1
answer426
viewsRijndael encoding based on 64 in C#
I’m doing a Rijndael encryption and I imagine I’m close to finishing it, but when I decrypt I’m in error: Invalid length of data to be decrypted. using System.Text; using static Array; class…
-
1
votes0
answers668
viewsSign json parameters with digital certificate C#
I’m trying to integrate with a webservice, which requires the message to be encrypted to PKS7 standard, but when I try to digitally sign the message, I’m getting this error: Exception: The provider…
-
1
votes2
answers282
viewsSum the random data
I have a code for a dice roller. Then the person will enter in the field the amount of data that will roll and after that the program will run the amount of data and add. So I made a array to…
-
1
votes1
answer1356
viewsPlace a combobox in a datagridview column
Using C#, with Entityframework and codefirst, I have the following classes in my models layer: public class Cliente { public int ClienteId { get; set; } public string Nome { get; set; } public…
-
1
votes1
answer949
viewsParameterized query error: Must declare scalar variable
I am aware of the existence of this question: Error in previous "Must declare the scalar variable" But it does not solve my problem. My situation is as follows: I have a common sql query: select id…
-
1
votes2
answers681
viewsC# - Windows Service only runs once
I am developing a windows service to run every 10 minutes, it inserts some values in the database, but I noticed that the routine only runs once. using System; using System.Collections.Generic;…
-
1
votes1
answer550
viewsSave form-data in webapi C#
I have the following code in Angular 2 for a form-data post method: upload(event) { let files: FileList = event.target.files; let formData = new FormData(); for (let i = 0, f; f = files[i]; i++) {…
-
1
votes1
answer431
viewsKendo Textboxfor allow only numbers in . NET
I don’t want to allow the user to enter characters in my field Textboxfor, and if so, I want to display a message that the field should contain only numbers. My code is below.…
-
1
votes1
answer588
viewsEntity Framework Relationship Error
I am developing a test project that I intend to include in my TCC, but I found a problem when relating two entities to create the Tablas in the database with the Entity Framework. Are they 'Post'…
-
1
votes1
answer414
viewsDeserialize JSON with Restsharp and Javascriptserializer
I am having difficulty deserializar a JSON. I am receiving the following content: "response":{ "account":{ "name":"Evandro Teste", "owners":[], "creationDate":"2017-07-07T07:18PDT",…
-
1
votes1
answer1819
viewsError: Entitytype<T> has no key defined. Define the key for this Entitytype
When running my application, the following error is generated: One or more validation errors Were Detected During model Generation: Ballpoint.DataAccess.Context.Booktable: Entitytype…
-
1
votes1
answer265
viewsInfinite Menu with recursive function
I’d like to know how to create a recursive interface. I have a set of menus, these menus are parents having children and so on, not existing a maximum number of children. I would like to find a…
-
1
votes1
answer102
viewsProblems while recovering data from BD with Entity 6.1.3 and Web API
I did a test project, called quotation to use the Web API and Entity. Well, I went to my web.config and created my connection string like this: <add name="CotacaoContext" connectionString="Data…
-
1
votes1
answer318
views -
1
votes1
answer314
viewsGet Google query Json with Webbrowser C#
I need to perform the following process, perform a google search and get the search information in Json format, how could I do this? I tried to do it this way, I used Webbrowser from C# and I…
-
1
votes0
answers73
viewsC# pagemethod autocomplete Materialize error
I cannot execute my c# function through the materialize framework autocomplete. It does not execute and returns no errors. With bootstrap it works. I’m using Asp.net without codebehind, all in the…
-
1
votes1
answer65
views -
1
votes2
answers1578
viewsHow to change position of all matrix elements by changing the row number by the column?
I tried this algorithm but the result is the same after this exchange int[,] array = new int[10,10]; for (int l = 0; l < 10; l++) for (int c = 0; c < 10; c++) { int temp = array[l, c];…