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
-
4
votes1
answer785
viewsError when trying to connect to SQL Server from webservice on IIS 7.5
I am getting some errors when trying to perform a query in SQL Server from a Webservice hosted on an IIS 7.5 server. My connectionString on the web.config: <connectionStrings> <remove…
-
4
votes2
answers1277
viewsHow to store a List<Object> in a database?
I am working on a project in C# where I have the following situation. I have a class that represents player: class Player { int ID; string Name; } and another representing a team: class Team { int…
-
4
votes2
answers3495
viewsDevelop in C# and . NET on Ubuntu Linux?
Recently I had to migrate from Windows to Linux, because my work notebook burned and I am using an old one with Intel Atom and only 2GB of RAM, I was insecure to use Windows because it is a very…
-
4
votes1
answer185
viewsSet using matrix in c#
I have the following matrix: a d k m s j e r t c f p I put such a matrix in an array as follows: char[,] matriz = new char[3,4]; matriz[0,0] = 'a'; matriz[0,1] = 'd'; matriz[0,2] = 'k'; matriz[0,3]…
-
4
votes1
answer256
viewsWhat is the difference between "Exception.Message" and "Exception.Tostring()"?
I’ve read some answers regarding try-catch and on the Exceptionbut I still have doubt about the difference in Exception.Message and Exception.ToString(): What’s the difference between one and the…
-
4
votes1
answer727
viewsFundamental principles REST
In this Article by Infoq, the author highlights the five fundamental principles of REST: Give all things an identifier Link things (resources/identifier) Use standardized methods Features with…
-
4
votes1
answer235
viewsUpdating collections with Entity framework
It is possible to update the Collection of an entity with one-to-many through his navigation property? public class Foo { public virtual IList<Bar> Bars {get; set;} public int FooID { get;…
-
4
votes1
answer79
viewsIs using "Touint64()" to format string correct?
Looking for a practical way to format string I came across the following: Convert.ToUInt64(string).ToString(@"00000\-000"). It is a good pathic to use this method to format strings? There is a…
-
4
votes1
answer48
viewsHtml.Editorfor losing value when rebooting the page
am starting my html.editorfor with "0.00" like this: @Html.EditorFor(model => model.Preco, new { htmlAttributes = new { @Value = "0,00"} }) However, when the user receives a validation message…
-
4
votes1
answer56
viewsSet a standard comment for every new project
I need to define a standard comment, so that in every project that is created it appears, without having to type it every time. Ex.: Author: Pedro H.
c# visual-studio visual-studio-2013 visual-studio-2015 commentsasked 8 years, 1 month ago Pedro Henrique 43 -
4
votes4
answers13213
viewsTextbox accept numbers and commas
I need that one textBox accept only numbers and commas. To accept numbers I’m doing so: private void textbox11_num(object sender, KeyPressEventArgs e) { if (!char.IsDigit(e.KeyChar)) { e.Handled =…
-
4
votes3
answers1435
viewsHow to convert an Object into an Array? (c#)
I have the following class: public string Nome; public int Cpf; public string getNome() { return Nome; } public void setNome(string nome) { this.Nome = nome; } public int getCpf() { return Cpf; }…
c#asked 9 years ago Hebert Lima 987 -
4
votes4
answers188
viewsSQL Embedded in C#
I have a C# application that uses a Mysql database with Entity Framework. However, the size of the database is ridiculously small, so I don’t think it’s worth having a Mysql database server just to…
-
4
votes1
answer63
viewsRemove "openfiledialog" from C#field
Good, I have an Openfiledialog in my program, but I didn’t want when I "open" to appear what is in the image... If I close the window, it is "openfiledialog" in Textbox, and I want it to be empty,…
-
4
votes2
answers170
viewsHow can I create events in a safer way?
I am creating events according to the code below, however it seems to be a somewhat dangerous way, since if there is a cancellation of the event it will accumulate every "shot" of the event, that…
-
4
votes1
answer865
viewsHow to use natural language processing in Portuguese with C#?
I need to find names of people and organizations in the text. I found that I need to use natural language processing for this, but I was only able to implement it in English using Stanford NLP for .…
-
4
votes1
answer76
viewsIs it possible to delete "C:" using Directory.Delete?
Using Directory.Delete("C:", true) deletes partition? Or it is just locked and does not run?
-
4
votes1
answer747
viewsSilent installation of Postgres and creation of the installer base
How I can embed the Postgresql database in my Winforms system installer? I can even put it as a prerequisite to install before system binaries, however I wanted to do a silent installation. I would…
-
4
votes1
answer112
viewsPush Notification Amazon SNS - Message cut
Hello, I’m using Amazon SNS to do push shots through C#. On the Android device, the message is cut in a row, and when you click on it, the application is redirected directly to the application. But…
-
4
votes1
answer90
viewsHow to list products from a single restaurant?
I registered my products in a particular restaurant. Being Restaurant(1) and Products(N), I have several products registered in a restaurant. How do I list these products for each restaurant? This…
-
4
votes1
answer74
viewsIs there Smtpclient.Timeout with infinite value?
Is there any way to put SmtpClient.Timeout with the infinite value? If so, how?
-
4
votes1
answer3589
viewsHow to assemble a page for printing within the application code?
I need to assemble a printing page inside my code, that is I will not print an existing document, nor the application screen, I want to assemble the code execution with the elements I want. I have…
-
4
votes2
answers97
viewsHow to bring an item list
I need to bring up a list of ITEMS, with only the Order id. The way I do it is this, but it brings me only one Item, I want to be able to bring all the items I have, with the Order ID. var…
-
4
votes2
answers2151
viewsHow to shift the focus from one Textbox to the next?
I’m trying to shift the focus of the field after the user writes 2 digits. Validation is ok, but I haven’t found a method to change focus. NOTE: It is a dynamic method used for various fields, so I…
-
4
votes1
answer1604
viewsSee Date only, in a Datetime field with LINQ
I’m generating a report in an app that I’m developing, but I have a little problem. When sending a query in a date interval, I can’t get anything, because it is a DATETIME (I can’t change to date…
-
4
votes1
answer1724
viewsI have the reference, but when I run the CLR says the reference is missing
I have this include in my project: System.Web.MVC.Ajax. However when running the application I get an error Runtime, in the archive web.config. If I comment on the error line on web.config, error…
-
4
votes2
answers335
viewsHow to receive multiple fields from a view in the controller
I need to create a multi-field Insert at the same time! My system has several tables and relationships and I am struggling at this point. I have this registration screen: With that code: @using…
-
4
votes3
answers2680
viewsHow to iterate over a dictionary?
I have seen several ways to iterate over a dictionary. There is one considered standard?
-
4
votes1
answer330
viewsHow to filter a List<Dictionary<string, Object>?
I have a list variableMatriz that is a List>. She has 108 items. The listMatriz[0] looks like this: What I wanted was for the list variableMatrizFiltrada to come only with items from the Triz…
c#asked 8 years, 11 months ago Joao Paulo 11,760 -
4
votes1
answer3294
viewsInvalid postback or callback argument
I’m having a mistake that came to nothing, I’m two days trying a solution to the same and so far unsuccessful. I have a form all made in webforms that when clicking the button to send the data is…
-
4
votes2
answers303
viewsHow to use the same ZPL code on different dpi printers
Expensive, For some time I have been using Zebradesigner2 software to create ZPL labels for printing on Gc420t and I’m not having problems. Now I have to generate ZPL code for label printing using…
c#asked 8 years, 11 months ago Carlos Lemos 324 -
4
votes4
answers2266
viewsHow to generate random numbers for Draw?
I need to generate numbers for a promotion, these numbers should go from 0 to 99999. How can I distribute these numbers randomly and fairly, without repeating numbers already distributed?…
-
4
votes1
answer1852
viewsHow to use @Html.Validationmessagefor to change the text box class
I bought a bootstrap template, the validation of the controls is done by a class that leaves the controls red. This would be the classes form-group has-error Only that I never used this way, I’m…
-
4
votes1
answer364
viewsHow to set Resharper to NOT add Summary comments
When using the Resharper (Stylecop) 'Remove Unused Directives in File' or 'Remove Redundant Code in File' function to delete a library from my project, Resharper removes it, but adds comments…
-
4
votes3
answers821
viewsProblem between C# system and Warsaw plugin (GAS Technology)
My project was built with the C#language. Everything was going smoothly, until some customers started reporting errors when opening my system. The error goes as follows: the client clicks on the…
-
4
votes2
answers812
viewsHow to count columns of an Httppostedfilebase txt file?
In the code below, it would work perfectly if I had access to path of the file uploaded on the client side, however, it doesn’t work that way. So I’d like to ask you guys to suggest another way to…
-
4
votes1
answer2880
viewsHow to Perform Procedures with Dapper
How can I run a store with Dapper?
-
4
votes1
answer39
viewsHow to set default properties for variables that start with specific text?
Is there any way to define the properties of a variable as default by the initials of the variables? Something like public string obsUsuario { get; set; }, all of which start with Obs by default the…
-
4
votes1
answer67
viewsHow to separate a fixed route from a variable route with Asp.net mvc5
I have a control that manages videos. I’m trying to make these two methods: [Route("video/categoria/{categoria}")] public async Task<ActionResult> Index(string categoria) { }…
-
4
votes2
answers164
viewsTypes of C#Methods calls
I have a question in the following case, not referring to dates, I used only as an example: Convert.ToDateTime("01/01/2016 00:00:00").ToShortDateString(); What is the origin of this method…
-
4
votes1
answer83
viewsTFS Api - Query error with Datetime
I am trying to perform a query using the TFS API where I need to get all the Workitems that have been edited from a certain date, however I get the following error: An unhandled Exception of type…
-
4
votes2
answers995
views -
4
votes3
answers3895
viewsDouble click on a Datagridview line transports the data to a form
Good morning to all. Next staff, I have a (query) form that contains the Datagrideview. And the registration form in another form. I would like to understand, how can I double click on a line of…
-
4
votes3
answers3226
viewsHow to identify if user is typing number or characters?
I have a textbox: <TextBox GotFocus="buscador_GotFocus" Tap="buscador_Tap" KeyUp="buscador_KeyUp" TextChanged="buscador_TextChanged" Name="buscador" Grid.Row="0" DataContext="Teste"/> In it…
-
4
votes2
answers119
viewsBest way to give Binding on objects from 1 to N - Asp.net MVC
I would like to know how best to give the Binding of data in the object FuncaoGrupo of my Controller. Each item in the list Funcoes will generate 4 Checkbox in View. I have the following class:…
-
4
votes1
answer356
viewsMVVM, Should I use Icommand on all controls?
Part of the MVVM is the use of commands through the interface ICommand. The question is, should I use commands on all controls? Even those that are not connected with the business rule? For example,…
-
4
votes1
answer109
viewsRandom Order with Entity Framework
I would like to translate the following SQL statement to an expression lambda: SELECT TOP 1 * FROM tbPessoa order by NEWID() What do I put in OrderBy that will be accepted? var pessoa =…
-
4
votes2
answers756
viewsHow to Download FTP Files
I need to download txt files that are on an FTP, I tried to use the following repackaged code below for this but it does not do what I need. The first parameter of the Downloadfile method is the URL…
-
4
votes1
answer114
viewsHow to optimize this code?
Is there any faster (performative) way to compare the current value with the previous (bank) value with Entity Framework? Instead of selecting Id for Id (according to property Discount code below),…
-
4
votes2
answers4252
viewsError: Undefined object reference for an object instance, how to resolve?
I have the method ChamadaEfetuada(MAluno) : bool checking whether the call was made to a particular student, this method is used in another method ChamadaEfetuada() : bool that instead of checking…