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
-
3
votes1
answer289
viewsHow to ignore files according to their extension in TFS?
In git you can use the file . gitignore to ignore some file extensions, but would like to know if this can also be done in Team Foundation Service or if there is something similar to ignore files…
-
3
votes2
answers880
viewsC# - How to check if a string has only spaces?
The propgram reads all lines of a file, and I have to check if in this line that he is reading there are only spaces, because if there are only spaces in it, it will be considered invalid by the…
-
3
votes1
answer408
viewsSqlconnection failure in C#
SqlConnection ABC = new SqlConnection( "Data Source=(local);Initial Catalog=Database1;Integrated Security=SSPI"); SqlCommand command = new SqlCommand(); SqlDataReader dataRead; I’m using this code…
-
3
votes1
answer198
viewsAndroid VM - Connection Error
Dear friends, good morning! I’m not getting connection on my android emulator, could anyone help me? I’m using Visualstudio Emulator for Android. My project is compiling, and running right, but I…
-
3
votes1
answer505
viewsConverting DOCX File to PDF C#
I have an application and need to convert a file DOCX for PDF without losing formatting. I found some DLL that help, but for corporate use have to buy license so it gets complicated. Complementing…
-
3
votes3
answers1650
viewsSend All Checkbox via Post
I’m trying to send all my View Checkbox, however, I can send only those selected via Formcollection Controller public ActionResult Index() { List<ListaCheckBox> listacheck = new…
-
3
votes1
answer81
viewsLazyload even putting . include(t => t.Model)
I’m having the mistake: Exception Details: System.Objectdisposedexception: The Objectcontext instance has been disposed and can no longer be used for Operations that require a Connection. When I…
-
3
votes0
answers84
viewsOn my site is asking for a dll that does not exist in my project
I’m having this mistake. The question is not how to solve, but understand why ERROR, if in my project this DLL does not exist. In localhost the site rises normally without this Dll. I just wish I…
-
3
votes1
answer269
viewsHelp with Action Edit and Delete returning null
I am developing an application but I have a problem with Edit and Delete actions. I have looked at the code several times, but calling the cited actions shows the following error: The Parameters…
-
3
votes2
answers3268
viewsVector ascending order c#
How to put odd numbers in ascending order? int c = 0; int[] numeros = { 10, 5, 20, 60, 1, 5, 8, 30, 11, 20, 25, 30, 50 }; Console.Write("Números pares"); foreach (int num in numeros) { if (num % 2…
-
3
votes1
answer60
viewsWhy are boolean values converted to string in the case Camel in C#?
Today I came across a peculiarity of C# which I had never stopped to pay attention to: When converting a value bool for string, the result is a text in Camel case: string verdadeiro =…
-
3
votes3
answers2266
viewsEntity Framework [Foreignkey]
Reading a tutorial on Entity framework, I came across a somewhat strange example for me. This example is about Dataannotation [ForeignKey] public class Student { public Student() { } public int…
-
3
votes2
answers200
viewsPatch Methods with Route and Authorize - webApi
I am building a project with webApi2 using Oauth. The system has (for example) User Registration (default), with permissions to View, Edit, New, Enable, Inactive, Delete. The standard methods of…
-
3
votes1
answer1179
viewsHow to start ASP.NET Status Service?
I set up mine Web.config with the following instruction: <sessionState timeout="30" mode="StateServer" /> But when I run the application (an ASP.NET site), I get the following error: Session…
-
3
votes1
answer159
viewsRun an Attribute constructor
How do I call the constructor of an attribute before the constructor of the decorated class? For example, I have my attribute: using System; namespace T.WinForm { public class TesteAttribute :…
-
3
votes1
answer1299
viewsHow to include a column that dynamically demonstrates image in a Gridview
I am generating a report and exporting to Excel, but as most reports the number of columns is dynamic and I am mounting the gridview dynamically. I need to demonstrate a column that displays images…
-
3
votes2
answers87
viewsC# Windows Forms Generic Object
I have a Desktop application in C# and need to load a dropdown with an option "All" and the rest coming from a database table. To load the dropdownlist I did something like this:…
-
3
votes1
answer306
viewsReceive post from one view to another view
I have two Views. Index Assincrona When access to index, he calls the View Assincrona and there’s a gif uploading to the whole page (Assincrona) be loaded and displayed in View. Controller Codes…
-
3
votes1
answer51
viewsConverts an SQL query into Entity Query
I asked this question in another forum, but the content of the discussion went another way so I decided to open this topic. Without running away from the subject, how do I perform this SQL query:…
-
3
votes2
answers1392
viewsViacep does not fill in user address data (Website on the .NET platform)
I’m developing a web application on the platform. NET and I thought of making the user type the zip code of his address and automatically he would fill the text boxes with data of street,…
-
3
votes1
answer100
viewsShow data from multiple models in the view
I have the following problem: In a view I will show data from 8 different tables and I have the following code that I put together to take the data to the view. public ActionResult Index() { var…
-
3
votes0
answers88
viewsUnity - Identify texture in Terrain X Y location
I have a Terrain in Unity, and I was wondering if you have any way to identify what the texture is in a certain XY position in Terrain. Example:…
-
3
votes2
answers247
viewsI need to get a description of the task manager process
I need to get the name of the process that is active on the screen, but I need to bring equal appears in Task Manager description. For example if I use processName it will bring "Chrome" I need it…
-
3
votes2
answers8686
viewsHow to Resolve "Object Reference not set to an instance of an Object"?
namespace RepositorioLivrosICC { public class RepositorioLivros { public static RepositorioLivros instance = null; private List<Livro> repositorioLivros; private int indice; public static…
-
3
votes1
answer412
viewsExtract icon from an application
I need to get the app icon that is open on the screen. App icons, browsers (examples pick up the Chrome icon , word icon and so on...) I tried to do so: Process[] listProcesses =…
-
3
votes3
answers118
viewsCode repetition in the same method
I have a method that generates some information. As I was in a hurry to deliver, I did and sent. Well, it turns out, seeing the code more carefully, I realized how inelegant it is. It was made to…
-
3
votes1
answer100
viewsWhat do Threads share when making Http calls?
The problem: I can’t login to a site more than once on Threads different. My application is a Console application. If I open several executable, can each do successfully login in one Thread, only…
-
3
votes2
answers1003
viewsHow to display total rows of a table in a label
I don’t know how to pull the total lines of a table, code: public string Eventos { get; set; } SqlCommand comando = new SqlCommand("SELECT count(*) FROM Active", conn); SqlDataReader leitor =…
-
3
votes1
answer542
viewsDate field 7 days after the current date in c#
I have a field in my application call txt_dataemissão in the case and the current date, and I have another field txt_deadline that I need you to show me in this capo the date counted with 7 days…
c#asked 7 years ago Junior Guerreiro 617 -
3
votes2
answers284
viewsHow to compare two string by marking the differences?
Let’s say I have the strings: Oi, meu nome é ítalo and Olá, meu nome é ítalo How to generate a result +- like this: Hi, my name is Italo Hello, my name is Italo The system must somehow mark the part…
-
3
votes1
answer70
viewsCheck if multiple columns contain a value?
Query: query = query.Where(t => t.campo1.Contains(filter) || t.campo2.Contains(filter) || ......); I wonder if there is any way that I do not need to keep informing all fields of the table, do…
-
3
votes2
answers161
viewsUse Contains in an integer C# field with lambda or LINQ
I have the following expression: query = query.Where(x => x.MeuCampoInteiro.ToString().Contains(filter)); But an exception is occurring: System.NotSupportedException: 'The expression…
-
3
votes2
answers1124
viewsc# - Unity - Error: Object Reference not set to an instance of an Object
I’m a beginner in C#programming, and I’m trying to learn how to make a 2d sidescroller game, but I couldn’t move forward from a part of the tutorial. This is because the camera simply doesn’t follow…
-
3
votes1
answer1234
viewsHow to make notification through the taskbar in c#?
For my application I’m developing I’m creating a icon which will be on the taskbar to show the notifications to the user and within it the user will have options such as : Quit, Open, Configure and…
-
3
votes1
answer325
viewsWhere to place asynchronous request methods following ASP.NET MVC standards?
I always put in the View Controller, is the right way to do it? I doubted it because I realized that I am filling my view with asynchronous methods, and I would like to leave it all separate so that…
-
3
votes2
answers223
viewsWhich database is ideal for my scenario?
I am developing a commercial automation system (C# and Windows Forms) that can be installed on one or several machines on the same local network. I did the part mobile system, where it is possible…
-
3
votes4
answers449
viewsWhen the textbox is null, the button will be off
When to write in the textbox, the button will turn on, but when you have nothing on textbox will turn off. I was able to make the button method turn on but could not do the turn off if the textbox…
-
3
votes1
answer1242
viewsDownload async with Webclient.Downloadfileasync
Today I have a class that downloads photos, but as there are many photos always above 5mil think I could take advantage with async method. Process multiple task at the same time. But I think I’m…
-
3
votes2
answers940
viewsFile import and read
I have an Asp.Net MVC project with Entity Framework 4 and SQL Server, where there is a Action who receives via POST an archive csv. Taking into account the use of memory, processing time and…
-
3
votes1
answer580
viewsPass Parameters to Store Procedure
Follow the Search Function Code public List<Pessoa> Buscar(string Nome) { using(var db = new MyContext()) { var Result = db.Database.SqlQuery<Pessoa>("EXEC SP_Busca_Cliente @Nome",…
-
3
votes1
answer142
viewsNullreferenceexception when calling function
I’m creating some unit tests for a class library that does manipulations in a database. The method being tested is this: public object ExecuteNoQueryOperation ( string spOrSqlInstructions,…
-
3
votes2
answers257
viewsWindows Forms Application - Visual Studio 2017
I realized I don’t have the choice of a project in Windows Form Application in Visual Studio 2017. I searched, and saw that there is the possibility to select the option during the installation.…
-
3
votes1
answer2685
viewsC# Convert object to an unknown list of objects
I have a question here. I have an object (Object) received by parameter. It can be a single object or a list of objects (List). Can I convert the object to a List object WITHOUT RECEIVING THE TYPE…
-
3
votes2
answers12946
viewsHow to limit decimal places using C#
I’m having some difficulty limiting the decimal places in C# . double x = 1,41293 I wanted to output only from 1.412 I have tested the following code: Convert.ToDecimal(x).ToString("0.00",…
c#asked 7 years ago Pedro Azevedo 435 -
3
votes1
answer433
viewsData handling in excel
I need to get the generated data from a proc save in any variable that is and make a UPDATE in a worksheet already existing in a fixed path on the system. It is possible to do this process via code…
-
3
votes1
answer203
viewsCompetition Server ASP.NET
I have a Silverlight application, which accesses a service in WCF. In this application I have a method Salvarnotafiscal(). This method calls a method Validarnotafiscal that verifies if there is…
-
3
votes1
answer87
viewsHow to refresh the context? ASP.NET
I’m starting to develop in ASP.NET and always have a small problem. When I need to generate a context (That class that will reference with the database), example below: I do the following procedure:…
-
3
votes1
answer78
viewsWhat "[ ]" means in the method declaration
I have the following method public BITalinoFrame[] Read(int nbSamples) { try { return device.ReadFrames(nbSamples); } catch (Exception ex) { WriteLog("Error reading the frames: " + ex.Message); }…
c#asked 6 years, 11 months ago Roberto Gomes 455 -
3
votes1
answer572
viewsHow to take the path of the subfolder that was "SELECTED " in the listbox by the user and save the file inside
The program I’m creating should take the following steps: First the user creates a subfolder to go saving the projects that were calculated by the program, as image and code below. When the user…
-
3
votes1
answer261
viewsC#,SQL,SQLITE How to return SQL command from an action
I have a question in C# and SQL commands, I am currently using Sqlite as a local database. In my application I enter entries in the database, so far so good, but I wanted to know if there is any way…