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
answer182
viewsHow to serialize a color with Json?
I have the following code, where I’m trying to serialize and deserialize a class that has two variables Color: static void Main(string[] args) { Color cor = Color.FromArgb(255, 255, 0, 0); Color…
-
2
votes2
answers1703
viewsHow to get information from an App.config
I’m doing a program where I want the user to put in the variable the number you need because it will vary from computer to computer what will be the number you need. I’m using App.config for that…
-
2
votes4
answers1120
viewsError Deserialize Json in C#Template
Friends, I am getting error to make the deserialize of the following JSON: { "Comanda": [ { "status": "Produzido (Codigo 3)", "estabelecimento_id": 18, "cliente_nome": "Marcos Manfrin",…
-
2
votes2
answers429
viewsHow to popular an object with the return of a Webapi query?
How popular the variable _clientes guy Cliente with the return of a consultation to a WebApi? Following the great suggestion of Damon Dudek I came across the error below: public class…
-
2
votes1
answer1136
viewsHow to generate 5 digit number automatically?
How can I generate a random number with 5 digits that do not repeat in the range [10000 - 99999]. I built the solution low and had generate in a loop the times I ran not returned repeated numbers,…
c#asked 7 years, 1 month ago Marco Souza 12,304 -
2
votes3
answers261
viewsHow to send selected data to an ftp server
I am developing a project in c# and right now I have to select a line from a Datagridview that I created, create a text file with that data and send the created file to an ftp server. I’ve done some…
-
2
votes1
answer83
viewsModeling - Model
I’m having trouble creating my models. Let’s imagine that I have 4 different types of products (Here as A,B,C and D) public class Produto { public int ProdutoId { get; set; } public TipoProduto…
-
2
votes1
answer390
viewsMask with Regex and replace to allow single digits and a single hyphen
What I need: A mask that works in the event keypress of a TextBox replacing what is not numerical and excessive hyphens with "". What is my difficulty: Check the entry of only one hyphen in the same…
-
2
votes1
answer180
viewsPage Content does not appear in Xamarin Forms
I’m having problems showing the contents of the pages. I created a Listview with some options, follow the code below: using System; using System.Collections.Generic; using System.Linq; using…
-
2
votes1
answer195
viewsIs it possible to store files in an executable?
I need to store a file, no matter its extension (it’s mainly an Executable) within another executable. It’s just, I’m compiling with Codedom an executable that inside it there is a file "special"…
-
2
votes1
answer339
viewsMy application does not give error, but nothing appears on the screen (Xamarin)
Developing and learning Xamarin. I took an example of Macoratti and decided to implement, because it comes to consumption of REST with Xamarin. I did everything as it is on the author’s site and…
-
2
votes1
answer341
viewsHow to call a database Function from the code
would like a help, i have the following Function that is in the bank postgres CREATE OR REPLACE FUNCTION public.get_id(campo character varying) RETURNS integer AS $BODY$ DECLARE _id integer; BEGIN…
-
2
votes0
answers40
viewsError writing file using Sqldatareader
I’m wearing a datagridview to show my table data and I have to create a file with that data, I tried to make the code I will post below but the using (SqlDataReader sqlReader = comm.ExecuteReader())…
c#asked 7 years, 1 month ago Pedro Azevedo 435 -
2
votes1
answer321
viewsHow to make an event work with Xamarin.Forms and c#
When I declare an event on my Mainpage.xaml, I cannot do the implantation. In the visual says that the implantation was made successfully, but in my cell is all white and can not even navigate it,…
-
2
votes2
answers356
viewsASP.Net - Browse Radiobuttonlist?
I have several RadioButtonList in a form, in the event of submitting the form I want to go through them and get the selected value. I tried that: protected void btnEnviarQuestionario_Click(object…
-
2
votes1
answer338
viewsAn unhandled Exception occured. I cannot understand this message, no detail comes
Personal that message: An unhandled Exception occured. It always happens when I try to consume my service REST. I first made an example, copying from Macoratti and it worked. Then I adapted it to my…
-
2
votes3
answers708
viewsCopy a file from the server to a local folder
I am developing a routine in order to copy files from the server to a local folder, but unfortunately it does not copy. The idea is that every minute the files are copied. I left one Sleep(5000)…
-
2
votes1
answer576
viewsHow to change the color of multiple textbox by looking at only one condition
I’m creating an app on VS2015 Windowsformaplication where I need to change the colors of textbox where the result is greater than, equal to or less than zero(0). This is how I’m working: if…
-
2
votes1
answer282
viewsHow to get a specific Json/XML object?
I need to get the contents inside <extract> to use in my application, but I’m not getting it. I tried to create a class with the same objects, I tried to use regex, but without success. I got…
-
2
votes1
answer810
viewsCreation of a Header that is used in the communication of a Webapi
I am creating a program that communicates with a webapi and is giving me this error in creating the header. I’m using this to create the header : var tempo =…
-
2
votes2
answers294
viewsIF within a class
I’m new to c#, and I wanted to do this: I have the dllimport class that is being used in another class. The problem is this, I want to pass the constant(dll path) according to the version windows 64…
c#asked 7 years ago Diego Aquino 179 -
2
votes2
answers42
viewsHow to create a date header but in the form of ISO 8601
I’m creating a communication with a web api and I needed to create a header date type but formatted to ISO 8601. What I want is to get the following output : Date: 2017-09-13T08:21:08Z My code is…
-
2
votes1
answer386
viewsAdd Mysql Connector to the instation package
I have a Windows Forms connecting to a database Mysql remote (is on a server). Basically, all it does is read data from a table, or write or anything. I am using the Entity Framework and my project…
-
2
votes2
answers2464
viewsASP . NET MVC and Javascript - Open modal with ID of the selected object in a list
INITIAL QUESTION I am working on an ASP . NET MVC project with bootstrap and need to open a modal for editing and deleting records from a list. The idea is not to leave the buttons next to each row…
-
2
votes2
answers122
viewsWhen consuming a service, error occurs in float or double fields in BD
When consuming the update service, this error occurs: The 'Datalib' Property on 'Release' could not be set to a 'System.Double' value. You must set this Property to a non-null value of type…
-
2
votes2
answers75
viewsConversion of bank image to use in a background
I am using the following code to put buttons with each category name, however I am not able to (I am not able to search) convert the background image, just give me the tostring option. {…
-
2
votes1
answer135
viewsBank without PK, but I checked the PK by the Entity. Is this a problem?
I’m having trouble with fields float. Well, that post will deal with another matter, but I thought I could somehow infer in this problem. I stopped to think and analyze the subject. This is the…
-
2
votes1
answer178
viewsGeneric Class Receiving a Generic List>?
In c# I can implement a generic class where 1 of the received attributes is a List<>? object something like: public class Negocio<TEnt, TDto, TDao, TList<coisas>> So you can call…
-
2
votes2
answers73
viewsCreate folder on every console usage
I took a program ready on the internet to create folder, so I tried to adapt it for me but I’m not getting. I’d like every time I executed it, to create a subfolder inside the main under a different…
-
2
votes1
answer122
viewsTreatment of exceptions of different types
try { await DoFooAsync(); } catch (Exception e) { if(e is TaskCancelledException || e is UnauthorizedAccessException) { // ... } throw; } The block catch from the above section checks the type of…
-
2
votes1
answer40
viewsRemove virtual properties from Typedescriptor.Getproperties()
I did a question how to use Sqlbulkcopy, the @Virgilionovic user showed me a code that uses Reflection to save any kind of list, but I do the TypeDescriptor.GetProperties() he brings the properties…
-
2
votes1
answer84
viewsWhen registering my class, it turns on the Onappearing method
I have been trying to notify with Xamarin and Xam.Plugin.Pushnotification. The problem is when I register the plugin. It does not work at the time when the method Up-to-date() is called. In reality…
-
2
votes1
answer506
viewsWhen to use And, Andalso and Or, Orelse?
I don’t know when to use the syntax Or or OrElse and/or And or AndAlso, because I don’t understand what difference it makes in the logic circuit. Being in C#, And = &, AndAlso = && and…
-
2
votes1
answer86
viewsHow to read an excel file and map
I would like to know how to read an excel file and then map to a datagridview. Code I tried on : var fileName = @"C:\Users\HP8200\Desktop\test.xlsx"; var connectionString =…
-
2
votes2
answers2890
viewsLoop "for" inside another "for" (nested repetition)
I’d like to spare those 9 repeated lines in my code: for (int n1 = 1, n2 = 1; n2 < 11;){ Console.Write(n1 + "x" + n2 + "=" + (n1 * n2) + "\t"); n1++;//1 Console.Write(n1 + "x" + n2 + "=" + (n1 *…
-
2
votes1
answer53
viewsWhen there is no string specification with the configured class where the Entity Framework creates the tables
I created a new project using Asp.Net MVC with EF, and did not configure the connection string property with the same name as the Context class : Dbcontext. Rodei enable-Migrations -> worked…
-
2
votes1
answer31
viewsSettings Many to Many code fast Migration
good afternoon! I have this many configuration for many in my project. public class Usuario { public Usuario() { this.LocalTrabalho = new HashSet<LocalAtendimento>(); } public virtual…
-
2
votes1
answer112
viewsError reading text file line by line
I am trying to read a very large file row by row and add in a list, but when it arrives at a certain point I get an error: System.OutOfMemoryException Is there any way to read this whole file in a…
-
2
votes1
answer448
viewsError of Mismatchsenderid
I had several projects on my console. I was able to receive push notification (PN). So I dropped all the projects and created just one. I made an app based on the step by step that a colleague…
-
2
votes1
answer30
viewsAdaptive Storyboard (WPF)
I have an animation in my WPF project and I wanted to know if there’s any way Storyboard can be responsive. As in the settings of Margin and Height/Width are responsive marking the auto option…
-
2
votes1
answer169
viewsProblems with the excel connection string
I have the following code snippet that connects to Excel, but returns the error: string sFileXLSX = ConfigurationManager.AppSettings["ExportPerformanceEntrega"]; string strConnXLSX =…
-
2
votes1
answer298
viewsHow to make a SUM in different table fields in the Entity Framework?
That’s the SQL that I have as an example, I would like to do the same with Linq? select SUM(iv.precoMediano * oi.quantidade) as total from orc_orcamentoItem oi inner join orc_insumoValor iv on…
-
2
votes1
answer721
viewsHow to join two tables using auxiliary table and LINQ
I have the tables People and Representatives, where in my application the person may or may not have representative(s). public class Conta { int PessoaID; string Nome; String Documento; } public…
-
2
votes2
answers178
viewsHow to create events in a for repeat structure?
My question is the following, I am developing a program (I am beginner) in C#. The part I wanted to improve on is the following: I’m wanting to create different events in a for structure. For…
-
2
votes1
answer544
viewsCheck null or empty fields in an entity without consecutive use of "if-Else"
In a system integration there are data updates on both sides, where you get the record of Side A and the record of side B. If there are null fields in A and these exist in B then A is supplemented…
-
2
votes2
answers212
viewsRecursive algorithm does not work
I have to solve an exercise, and it says: Do a procedure that receives an integer and positive n number. The procedure shall print all numbers in the range 0 to n which are divisible by 2 and 3…
-
2
votes1
answer257
viewsError trying asynchronous connection
I’m trying to do this way not to crash the application while waiting for the server to accept the connection. I saw that you can do with async and the await. But while trying to use them to wait for…
-
2
votes1
answer213
viewsHow to repeat number at a maximum?
I have two whole: n and m: n: Number that will repeat in the index; m: Index maximum. What I need to do is simple, is to return a number that is <= m on the basis of n. When n is larger, it will…
-
2
votes1
answer447
viewsHow to split by numbers inside the string?
String following: 1No começo Deus criou os céus e a terra. 2A terra era um vazio, sem nenhum ser vivente, e estava coberta por um mar profundo. A escuridão cobria o mar, e o Espírito de Deus se…
-
2
votes2
answers1578
viewsHow to Perform IF function when selecting Combobox item?
I wanted to know how to make one if function only when the combobox have any item selected. I am making a program in windows Forms and I need a if to limit the program to only do that function when…
c#asked 6 years, 12 months ago Pedro Azevedo 435