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
votes3
answers535
viewsFinding pg_dump and pg_restore (Postgresql) on my C#PC
To perform the backup and Restore in a Postgresql database using C# you need to locate some files like the pg_dump and pg_restore. How do I make a function so that it is possible to find the files?…
-
2
votes0
answers486
viewsHow to capture the frequency of sound being picked up by the microphone
The question is simple, How to determine the frequency of the sound obtained by the microphone in c#? I want to build an instrument tuner for a program I’m developing... Do you have a library ready?…
-
2
votes1
answer34
viewsFiltering result by category
using (ObjectContext ctx = new ObjectContext("name=kinectEntities")) { ctx.DefaultContainerName = "kinectEntities"; ObjectSet<produtos> query = ctx.CreateObjectSet<produtos>(); foreach…
-
2
votes2
answers420
viewsC# Web Forms - Missing Session
I have an application in Web Forms that stores the session when the user logs in, with a time limit of 21 minutes without using the application to expire the session: <sessionState timeout="21"…
-
2
votes2
answers74
viewsCreate a new record based on another with Entity
I need to add some columns to a database as follows: save a comic line to a variable Market novo = new market(); novo = context.Markets.where(blabla).First(); change a row column novo.ParentID = 50;…
-
2
votes1
answer786
viewsView Model receiving Null values
After a query in BD, my query returns some null values in some attributes and when passing the values to the model: ViewModel.Participantes.Add(new RelParticipantesInscritosAtividadeVM { RA =…
c#asked 7 years ago Rafael Christófano 365 -
2
votes2
answers9692
viewsEntity Framework Query with Inner Join and Where
I am making a query using Inner Join of some tables and a Where with only one condition, but the data is not returned in EF,the same query in Mysql works and returns data. Follows the code: string…
-
2
votes1
answer113
viewsWCF out bool parameter
I created a Webservice WCF, and at the interface IService1.cs I put the signature of the methods [ServiceContract] public interface IService1 { [OperationContract] bool insertConsulta(BConsulta…
-
2
votes1
answer165
viewsEntity Framework, you doubt the solution structure (app.config and package.config)
I started a solution with Entity Framework code-first. In the solution structure, I separated the domains from the other EF files (context, etc.). That is, the domains were in a separate project.…
-
2
votes1
answer83
viewsjavascript result for method in parameterized controller
I am trying to send the result of a Webapi that is consumed via javascript on the page to a method in the controller that will make a persistence with this data this is javascript…
-
2
votes0
answers205
viewsList overwriting items
I have a Data Object List, which has two attributes: Name (String) and Transactylock (Int) It’s the Data List However, with each execution of the executarSchedule method, it overwrites the item…
-
2
votes1
answer8466
viewsFind item in a List with Contains method
I have a Data object, which has the attributes name(string) and transactBlock(int). I have a Data List called dataBlock. I want to see if this list has an item already with the same name and…
-
2
votes2
answers387
viewsFind Broadcast address for sending UDP message
My Wi-Fi network interface contains the following settings: Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : home Link-local IPv6 Address . . . . . : fe80::95d7:bda0:eac3:ebf7%5 IPv4…
-
2
votes1
answer467
viewsAccess another project’s controller in the same Solution
Guys I have 3 projects in the same Solution: Knockdocweb, Kanodockmodels and Knodockapi as shown in the image below: When I compile the project it starts Kanodockweb, but I want to Access a…
-
2
votes3
answers2857
viewsHow to make a string in Appsettings and use it later
How can I make a string in Appsettings, and then use it, for example, the string in Appsettings is this: string example = "example" And take the value that’s in the Appsettings string and put it in…
-
2
votes0
answers315
viewsC# Bina with Usb Fax Modem
I would like to know a way to get the phone number of a fax modem usb, using C#. Example: I have a computer with a fax modem usb connected to a telephone line, when someone calls me my system picks…
-
2
votes3
answers1886
viewsCheck if a date is valid
I have a college job where I need to check if a date is valid but I can’t use the classes Datetime and Timespan. With these classes I can do it, but without being able to use them by the criteria of…
c#asked 7 years ago Thiago Saracine 45 -
2
votes1
answer35
viewsUnreachable code Detected on bank connection
Oops good night, Personal to with a doubt that it is something silly, is that I am not accustomed to use an external connection class in the development, had this bad-habit but now I went to use and…
-
2
votes1
answer918
viewsObject Reference not set to an instance of an Object
I’m learning to do App using the Xamarin 2017, and when I try to connect to the database I created via SQLite, the application shows this error: Object Reference not set to an instance of an Object.…
-
2
votes1
answer2339
viewsHow to make a sum of two matrices generating a third in c#?
I can’t do it, I tried using the FOR loop and also the IF to store in the matrix before making the sum, but my knowledge in c# is scarce. and the matrix is a 2x2.
-
2
votes1
answer46
viewsArraylist: Is that right or is there a better way to do it?
I know a bit of java, but now I’m venturing into C#, but a question came up here: In java we instantiated an Arraylist like this: ArrayList<Tipo> nomeArray = new ArrayList<>(); We…
-
2
votes1
answer1134
viewsSelectlist with Viewbag
I’m trying to make a SelectList using ViewBag. But when I run my code it shows where the information I’m trying to access is, for example: NomeProjeto.Models.NomeModel I’m using the following code…
-
2
votes0
answers437
viewsChange the background color of a selected item in a menu listview in a Master Detail Page with Xamarin.Forms
When I select an item from the menu, it gets a default background color from Xamarin, but I would like to change that color. I’m using a Masterdetailpage in Xamarin.Forms…
-
2
votes0
answers40
viewsWork with two treeviews and their WPF items
I have two similar treeviews, but with different items, in this case, one of them brings a dialogue in Portuguese while the other should bring the same dialogue in English. I have two text boxes,…
-
2
votes1
answer1323
viewsMap View - Entity Framework
I know it has been asked something similar, but in the answers I found said that to map the view should put the Dataannotation [Table("view name")] or configure in the Fluent API I created a view in…
-
2
votes2
answers1331
viewsHow to remove the value of the last Textbox position with Substring?
How to remove the value of the last position of the TextBox with the Substring? Suppose the TextBox receive a value with this mascara = 0,00%, however, I just want to save the numbers and not the…
-
2
votes1
answer289
viewsSql Reader returning null value
I’m running a datareader, however does not return any value, already checked in the table and conditions (where) of select exist in the table. The code goes below: public void consulta() { string…
-
2
votes1
answer70
viewsProblem running eventhandler
I have a class, which is executed under a button, it makes two select in a bank. apos, need to take these two data and make available to use in a second form, I’m trying to make EventHandler,…
-
2
votes1
answer306
viewsPlayerprefs Unity3d
I’m developing a game for android but I’m having a hard time saving the type of input. For example in this game the user can choose whether to play on touch or accelerometer, in Unity + remote works…
-
2
votes3
answers216
viewsWhat are the advantages of working with Fluent Interface with LINQ?
What are the advantages of working with a fluent LINQ interface? I have that code: Employees.Cs. namespace LinqConsulta { class Empregados : List<Empregado> { public Empregados Lista() {…
-
2
votes3
answers783
viewsHow to return values from two different tables?
I’m working on a script for auto complete that you should search two tables of the same level (Courses and Packages) (without relation) and return the merged values in a single list. The problem is…
-
2
votes2
answers356
viewsMerge two items of an Ilist into one item by Id
In my class has: Id Venda Devolucao I have a IList of that class, and in that IList has [0] classe Id = 100, Venda = 230.00, Devolucao = 0; [1] classe Id = 100, Venda = 0, Devolucao = 50.00; [2]…
-
2
votes1
answer774
viewsTransaction with multiple queries
I was visualizing that question, and to try to answer I decided to perform some tests where I could see the following problem: When conducting multiple queries to the Database via Entity Framework…
-
2
votes1
answer47
viewsConvert "-12.0000"(string) to -12.0000(double). Is it possible?
It is possible to convert "-12.0000"(string) for -12.0000(double) ? Follows code: var valor = "-12.0000"; var result = Convert.ToDouble(valor, CultureInfo.InvariantCulture); //-12 <--- perde…
c#asked 7 years ago Matheus Miranda 5,375 -
2
votes3
answers1724
viewsAdd Datagrid column with valid values only
I’m using this function to add a column of my datagrid public void Somatorio() { decimal total = 0; foreach (DataGridViewRow row in dgv_inico.Rows) { total +=…
-
2
votes1
answer96
viewsInsert an array into a Key Json
I need to get a Json as follows: { "razao_social": "Loja do Zé LTDA", "nome_fantasia": "Zé Store", "tipo": "J", "observacao": "Cliente com ótimo histórico de pagamentos.", "emails": [ { "email":…
-
2
votes3
answers97
viewsGroup repeated values of Dropdownlist fill sql statement
I’m taking information from a table and filling out a DropDownList, but I have a lot of information repeated and I would like to group the values so that they are not repeated in the DropDownList.…
-
2
votes1
answer838
viewsHow to validate Date with Regex?
I am trying to capture a date inside a string using regex, but when I try to recover the part of the string returns me the following error: analyzing " TARIFF:([ d/]+)" - Unrecognised exhaust…
-
2
votes2
answers97
viewsLoop in Constructor c#
I’m trying to set mine Senha using the md5, but there is a loop at settar. public class Usuario { public int ID { get; set; } [Required] public string Nome { get; set; } [Required] public string…
-
2
votes1
answer444
viewsHow to project an image on the big screen?
I’ve looked on the Internet and I can’t find. How do I project an image onto the screen ? Example: On the main screen(notebook) show executable(windows Forms), and on the second screen show an image…
-
2
votes1
answer923
viewsGenerate dynamic HTML with ASP.NET
Good people, I have a project, and I need to generate a card with dynamic HTML, pulling from an sql server. The case is as follows, I have an html CARD, all stylized. Which in this case is the code…
-
2
votes2
answers90
viewsIn C# is there variadic Arguments (infinite arguments)?
In languages such as PHP 5.6 and Python, it is possible to define "infinite arguments", (in PHP it is called variadic args) in a function/method. For example, it is possible to define a function…
-
2
votes1
answer1225
viewsHow to insert text into an existing PDF?
I have a contract template ready and with nothing filled out. I need to fill out the requested information with what will be typed in some TextBox. How can I do this using iTextSharp?…
-
2
votes1
answer112
viewsI made a sum with lambda and is not working as expected
I need to make a general sum for total and profit. If I made a sale with 4 items, I’m seeing in my grid four sum and that’s not it, even if it repeated 4 times, but it should be just a sum. I need…
-
2
votes1
answer1688
viewsClick button call different methods
I have a button that calls the click event btn_Salvar in my form. How do I call this event different methods according to who created the form in which the button is contained? EDIT: Explaining…
-
2
votes1
answer571
viewsHow to call asynchronous method in class builder?
How do I call a method marked as async in a class builder?
-
2
votes1
answer187
viewsConfigurationmanager.Appsettings returning different values in different environments
I don’t know much to post to help the question, so if you want to know more just mention the comments. In the web.config, inside appSettings, has the tag <add key="apiManagerUrl"…
-
2
votes2
answers264
viewsHow to program a single check-box to checklistbox items?
I need to program in a single check-box, so when it is "marked" select all my files present in a checklistbox and "unchecked" the reverse. I created a check-box in my 'mark/deselect all'…
-
2
votes3
answers2176
viewsQuestion how to increase input size according to div size using bootstrap
I am having difficulty increasing the size of my inputs using the bootstrap classes, I would like to leave them according to the sizes of my div for example, in a Row with 12 columns I create the…
-
2
votes0
answers129
viewsImprove C#socket performance
Client.Cs public void start() { this.Socket.BeginReceive(Buffer, 0, Buffer.Length, 0, new AsyncCallback(beginReceive), this.Socket); } private void beginReceive(IAsyncResult ar) { try { Socket…