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
-
5
votes1
answer1874
viewsHow to collect data from a web page?
Web data collection, or Web Scraping, is a form of mining that allows the extraction of data from web sites by converting them into structured information for further analysis. Present here your…
-
5
votes2
answers106
viewsDifferences between variable statements in C#
What is the difference between these statements: Classex xx = new Classex(); var xx = new Classex(); Classex xx; If in the end I can use everything in the same way (methods, properties...) Ex.: I…
-
5
votes2
answers501
viewsC# | Enlarge the Console Application window
How Do I Enlarge the Application Console Window in C#? I use Visual Studio 2017 Community. My program will be done in Console Application, I need to change the size of the Console window being…
-
5
votes2
answers56
viewsWhy is it that when I delete or edit the record from table x it is also removed from table y?
I have a system in ASP MVC with C# using Entity framework. I have the table Pedidos and Agenda. On the table agenda I have a column with the id of the request. When the order is canceled, I have to…
-
5
votes1
answer1303
viewsWhat are the scenarios in which C# has an advantage over other languages?
Here on the site have some similar questions, for example, What are the ideal use scenarios for Node.js? and Why choose C instead of C++ or C++ instead of C? I would like something in this sense but…
-
5
votes0
answers806
viewsAllow Camera and Microphone access to a Webview by Xamarin Android
I created an app webRTC that allows me to do streaming audio and video via using javascript, now I need that by my Android I can access through an app I’m developing. I’m wearing a Webview to load…
-
5
votes2
answers131
viewsMysql DATE type is displayed as DATETIME on a datagrid
I create a very simple database with the following command: CREATE TABLE IF NOT EXISTS `ABC`.`Socio` ( `idSocio` INT NOT NULL, `SocioNome` VARCHAR(45) NULL, `SocioDataNasc` DATE NULL, PRIMARY KEY…
-
5
votes1
answer2397
viewsMysql connection problem - Connection must be Valid and open
I’m having a problem at a Windows Form in C# using Datagridview. The following is done: by clicking on a datagrid line the information of the respective line, saved in a database, must appear in a…
-
5
votes2
answers1346
viewsDifference between ADO.NET and Dapper
What are the differences between Orms? When to use one and when to use the other? What are the disadvantages of each?
-
5
votes3
answers1448
viewsConverting word file to pdf
There is a free library that I can convert word file to pdf ? I have word file saved database with type varbinary(MAX) and I recover as byte[] in C# and I want to convert word to pdf to show on HTML…
-
5
votes2
answers104
viewsCommunication of c# and c++
How can I make the C# code call a variable that is in a C++ file for example. Knowing that I am using Visual Studio. Code C++: #include "stdafx.h" #include <iostream> int main() { int test =…
-
5
votes1
answer663
viewsViews do not recognize @model, @Viewbag, @Viewdata
I am using Mono 5.10.1 and Visual Studio Professional for Mac (Version 7.5.4 build 3) Views do not recognize tags like @model, @Viewbag and @Viewdata, either in older projects that were originally…
-
5
votes1
answer1890
viewsDatetime.Now or Datetime.Utcnow
What’s the difference between DateTime.Now and DateTime.UtcNow ? DateTime dateNow = DateTime.Now; // retorna {01/08/2018 18:28:15} DateTime dateUtfNow = DateTime.UtcNow; // retorna {01/08/2018…
c#asked 7 years, 1 month ago Matheus Miranda 5,375 -
5
votes2
answers828
viewsAbort Thread through another C#process
I am developing an application in ASP.Net 5.0, where it needs to start a task through a Thread Secondary, as the example below: //Inicia processo de pesquisa var ppBlo = new ProcessoPesquisaBLO();…
-
5
votes4
answers283
viewsCreate list with more than one element as if it were multidimensional
I need to receive these pairs of data from the bank, and I’m thinking of a way to bring the values without creating an object, because I think it’s unnecessary in this case. It is possible to create…
-
5
votes2
answers474
viewsValidation without "Modelstate.isValid"
I have the following scenario: [HttpPost] public PartialViewResult Create(string dados) { var clienteViewModel = DeserializeJson<ClienteViewModel>(dados); if (ModelState.IsValid) { } // Não…
-
5
votes1
answer433
viewsAutomapper Entities Viewmodel
I am with a scenario where my context returns a query referring to two entities User and Cartaocreditousuario, as the following scenario below. During automapper action on my Viewmodel, is not…
-
5
votes2
answers933
viewsTake the index of a value in an array
How do I get an index of a value of mine array? For example: char[] letras = new char[]{'a','b','c','d'}; In letras, i would like to pick up the value index b for example. How do I do this in C#?…
-
5
votes1
answer696
viewsHow to set up languages in Asp.net Core
I’m setting up the AddLocalization So the problem is that Resources are in a separate class library of the project and I don’t know how to set up. services.AddLocalization(options =>…
-
5
votes1
answer728
viewsWhat is and what is the explanation for type-safe in C#?
Not being able to understand the concept of type-safe in C# and what is its use, since C# is type-safe.
-
5
votes1
answer138
viewsScroll Infinity ASP NET MVC C#
Good afternoon, I am implementing an infinite list in Asp net mvc and I have some questions about what is the best way to do this. I implemented using partial view, making a request via ajax and…
-
5
votes1
answer280
viewsHow to make the properties of a User Control accessible in XAML?
A User Control can be used for various purposes, but I would specifically like to know a simple example of how to create a User Control any that returns any value. For example a Numericupdown:…
-
5
votes1
answer52
viewsWhat is the need to inform the parameter "Order" in the object of type Indexannotation?
I am creating indexes for some columns that will be used in a query with Where(). The intention is to make the search faster. Until then I was creating like this: Property(x => x.Documento)…
-
5
votes2
answers120
viewsHow to use C#quotes?
I’m starting to program in C# and I’m feeling some difficulty with quotation marks when I need to paste some text. In Python I could use the triple quotes to paste some text that there was line…
-
5
votes2
answers203
viewsWhen to use "Try catch" in layered application?
Let’s say I have my layers Controller Business Repository so it is necessary to create this block in the 3 layers or create only in the controller? If I do this she ensures that every code that is…
-
5
votes3
answers1590
viewsCheck that all fields of an entity is null
I’m doing a verification of an entity view model in the C# and I have to validate if all fields are null, because I have to require at least 1 filter to continue the routine. Doubt: What better…
c#asked 6 years, 8 months ago Victor Laio 2,043 -
5
votes1
answer1315
viewsHow to delete all files from a directory
I would like to know how to delete all files from a directory. Suppose I need to delete all files from the Test folder in C: test.
c#asked 6 years, 6 months ago Ronison Matos 313 -
5
votes1
answer225
viewsAsynchronous programming C#
How would my application behave in a scenario where I perform an asynchronous query in the database and then manipulate the returned value? The application would wait for the query to be finalised…
-
5
votes4
answers197
viewsCorrect syntax way in object instance
In the instance of an object, we can: Pessoa pessoa = new Pessoa(); and we can also: Pessoa pessoa = new Pessoa(){ Nome = "Nome", Id = 0, Situacao = true }; What is the best or most correct way to…
-
5
votes1
answer137
viewsHow does the request session work?
An idea arose among the developers to use the standard of Session per request - Session by request. Researching on the subject, I found some topics in the OS that generally said that the indication…
-
5
votes2
answers2603
views -
5
votes1
answer270
viewsConsume entity repository directly from the application layer
I have a scenario where I need to search for a list of Active Employees with Entity Framework and display them on the screen (I need to convert to Dtos before displaying - what I do through the…
-
5
votes1
answer239
viewsHow to configure Entity Framework Mapping 1:N using inheritance
I have two classes: Pessoa and Usuario. The class Usuario inherits class properties and methods Pessoa. I am using the Entity Framework and I believe is doing the mapping wrong. That’s why the…
-
5
votes2
answers252
views -
5
votes1
answer555
viewsSome questions about socket
I’m taking a look at an example of microsoft itself and I’m having some doubts. Example taken from this link: https://msdn.microsoft.com/pt-br/library/bew39x2a(v=vs.110). aspx Let’s imagine a chat…
-
5
votes1
answer789
viewsUse Ienumerable or Icollection?
I want to create a 1 x N mapping using the Fluent API of Entity Framework, something like: a shopping cart has several products. In my class stroller, I have a navigation Property, which is a…
-
5
votes2
answers406
viewsTolist vs Typed Tolist
I was reviewing some methods of an ASP.NET MVC project and found some cases where it is used only .ToList() and others in which it is used .ToList<type>() (where type is an object type used in…
-
5
votes2
answers367
viewsArtificial Intelligence for Games in Unity
I’m creating a game at Unity, and I’m looking to do some bosses, but for that I need to study artificial intelligence, and I have no idea where to start, I looked for books but they are very scarce,…
-
5
votes1
answer459
viewsError Connecting Postgresql to Entity Framework
I am trying to connect the EF in Postgresql. You are presenting the following message: An unhandled Exception of type 'System.Configuration.Configurationerrorsexception' occurred in…
-
5
votes1
answer386
viewsHelp with 16bit Hexadecimal RGB colors
So I’m creating an editor of a PS2 football game in C#. And the game’s "color system" is RGB, and by then it was all going very well, because I was coming across "normal" Hex codes in the game like…
-
5
votes1
answer151
viewsHow to avoid repeating "using" in ASP.NET MVC?
I have a controller where several moments have a code similar to this: public ActionResult ListarProduto() { using (DBModels db = new DBModels()) { return View(db.Produto.ToList()); } } How not to…
-
5
votes4
answers150
viewsHow to use unsafe code on a Web Site
I was looking to practice the use of pointers in C#, so I created in a website the following method: public static Nodo[] MontaTree(){ //... código ... } Obviously the above code does not allow to…
-
5
votes2
answers700
viewsDropdownlist quantity Items
Good morning, I’m using dropdownlist in the asp.net to load some data coming from the database, however I do not know the amount that will be shown, because it depends on the fill in the database. I…
-
5
votes2
answers355
viewsWould using underline in C# be good practice?
The question refers to development pattern and good practices. I come from a Javascript and PHP world, work for 12 years with development, and I’m very used to using underlines _ variables, such as…
-
5
votes1
answer107
viewsIf everything in C# inherits from Object, why aren’t all types by reference?
If, for example, a struct type inherits from the class System.ValueType (who inherits from System.Object), why it, and the other types by value, are not allocated in the heap? By making a Boxing, we…
-
5
votes2
answers1480
viewsHow to add references in Visual Studio Code?
How can I refer dll’s in visual studio code? I’m trying to compile a c# project with MVC architecture.…
-
5
votes2
answers76
viewsForeach at a checklist in c#
private void Checked() { foreach (ListViewItem listItem in listView.Items) { if (cb_selectAll.Checked == true) { listItem.Checked = true; } if (cb_selectAll.Checked == false) { listItem.Checked =…
-
5
votes1
answer41
viewsEF6 - Rushed load bringing less aggregated data than database data
I’m having the following problem with my relationships in Entity. When I seek for example a Bank Account by Id : return _databaseContext.Clientes .Include(x => x.Enderecos) .Include(x =>…
-
5
votes2
answers330
viewsDifference between Find, Exists and Contains of the List<T> class
I’m working with the class List<T>, so I came across some research methods, if I may call it: Find; Exists; Contains; I was in doubt of what the difference between them, so I searched on the…
-
5
votes1
answer1118
viewsReturn Dowload Excel via MVC Controller
I have a method that generates an excel file and writes it in a directory, but then I take the path of the directory and I need to download the excel file, but nothing occurs, no error. Can anyone…