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
votes3
answers2170
viewsHow to compare two List and delete repeated fields?
How to compare to lista1 and the lista2, excluding the items repeated in one of them?
-
4
votes2
answers1169
viewsRemove HTML tags
In terms of efficiency and performance, which of these codes is the best option to remove HTML tags in a string? Option 1: string ss = "<b><i>The tag is about to be…
-
4
votes2
answers117
viewsCan separating static methods into several classes have a negative impact?
In question of organization it is relevant to separate methods into different classes. If we organize the methods in different classes in order to create a better organization, we can have a…
-
4
votes1
answer999
viewsAccess Object Property with a string
Pupil: public class Aluno{ public int Id { get; set; } public string Nome { get; set; } public string Sobrenome { get; set; } } Now I need to access the student’s Name and Surname through a string,…
-
4
votes2
answers855
viewsMake comparison using String.Contains() disregarding Casing
I need to check if a given term exists within a string (in SQL is something like like '%termo%'). The point is, I need this done without considering Casing of the two strings. How can I do that?…
-
4
votes1
answer1323
viewsMake comparison using String.Contains() disregarding accents and case
I need to check how to make a comparison between strings, in C#, using the method Contains() that so disregards the sensitivity of accents and marry of a string. Example: var mainStr = "Acentuação";…
-
4
votes3
answers177
viewsCreate a table with dates
I am creating a table and I need the columns to be created as follows: Mon, 23 Nov | Tue,24 Nov | Wed,25 Nov | Thu,26 Nov | Fri,27 Nov | Sat,28 Nov | Sun, 29 Nov To create the Table I pass a date…
-
4
votes1
answer1504
viewsAdd line to a datatable
I need to add a row in a table at a given position. I have the following methods: public void criarTabela(DateTime dia) { tabela = new DataTable(); switch (dia.DayOfWeek) { //case DayOfWeek.Monday:…
-
4
votes3
answers155
viewsWhy should I use the typeof keyword to assign a data source to a Bindingsource.Datasource?
For example: BindingSource bs = new BindingSource(); bs.DataSource = typeof(object); Why should I use typeof(object) instead of just object or even "object"? Edit: As other people have asked,…
-
4
votes1
answer90
viewsbring menus and active submenus C#
I have to make a query through the menu I have to bring only the active submenus, see my code. return context.Set<Menu>().Include("MenuGroups") .Where(x => x.Id == id &&…
-
4
votes2
answers396
viewsConvert string value to hexadecimal without changing format
I am using the following code in a Class. public Int16 Endereco = 0x7302; byte[] Data = BitConverter.GetBytes(Endereco); Array.Reverse(Data); [...] I would like to receive the value for the variable…
-
4
votes2
answers7812
viewsAccessing Components from Another Form
I have two Forms in my application. A Form for data from an engine that has the following fields: txtPotencia, txtTensao and txtCorrente. I would like to access the values filled in these TextBox…
-
4
votes1
answer144
viewsSeveral Books for Author
Recently I asked a question about my problem, but it got a little hard to understand, here I will try to summarize my problem. I’m using ASP.NET MVC. I have 2 tables: Autores and Livros, where 1…
-
4
votes3
answers8500
viewsAngular + ASP.NET MVC: Does it make sense?
I’m starting to study Angular2. As I am working a lot with . NET I decided to do a project with ASP.NET MVC 4 and Angular2. Giving a read on hello world of Angular I noticed that Angular has its own…
c# asp.net-mvc software-architecture angular typescriptasked 7 years, 7 months ago Marllon Nasser 3,845 -
4
votes1
answer514
viewsPassing an object to a Bootstrap modal
I need to pass a database object to a modal when I open it to display the object information. Is it possible to do that? follows the cshtml of the view in which the modal button is called, it opens…
-
4
votes2
answers960
viewsWhat is the purpose of the 'Let' statement in a LINQ query?
I have the following LINQ query: var source = from em in query select new { Id = em.UniqueID, Data = em.Data == DateTime.MinValue ? "" : em.Data.Value.ToString("dd/MM/yy HH:mm") }; The estate Data…
-
4
votes3
answers1167
viewsEpplus row and column last cell - C#
I want to select a range from the first to the last cell filled in the row or column. In VBA the code is as below using Range(Selection, Selection.End(xlDown)).Select Range(Selection,…
-
4
votes1
answer561
viewsMany Relationship Query for Many Entity Framework
I’m new to Entity Framework and Linq, so my doubt may be very simple, but it’s breaking my head. I have two entities: public class Fornecedor { public int FornecedorId { get; set; } public string…
-
4
votes1
answer77
viewsI can’t save a Dictionary
I have a page that may have unauthorized access, open for reading or open for reading and writing. Even if the page is completely closed, the owner of the page can choose some users of the system…
-
4
votes2
answers1536
viewsConvert string in binary format to PDF
I would like to know how to Gero a PDF file through a string with binary values, the values should actually turn a text (according to the ASCII table) and be written in PDF. I tried to do it this…
-
4
votes1
answer1918
viewsWEBAPI AND A3 CERTIFICATE - TOKEN
Can anyone here use A3 type certificate for a WEBAPI ? Because when I test it in debug (i.e., local), everything works normal. But if I compile, and put in the IIS application, keeps returning me…
-
4
votes2
answers662
viewsConvert HTML as image
I own a string with the page’s HTML, is there any way to save it as an image? Render the whole page as an image, and if possible, store it in an MemoryStream.
-
4
votes1
answer392
viewsWhat is the advantage of using Tag Helpers in ASP.NET Core?
I am studying the ASP.NET Core and came across the tag helpers when I ran the scaffold of a view. I found interesting the new syntax, the code is more readable at some points, however, the inclusion…
-
4
votes1
answer488
viewsUsing Concat to concatenate array of strings
I was seeing about strings and that they are immutable and cannot be added to them in quantity otherwise they will be very slow. The recommendation is to use the StringBuilder. But I also saw that…
-
4
votes1
answer2169
viewsBest practices when filtering a query with Entityframework
I have a web api method that receives a model from a search form and according to its values, it starts to filter the result of this search, as an example below. public HttpResponseMessage…
-
4
votes2
answers180
viewsChange of object in inheritance
I have the following classes: class Funcionario { } class Coordenador : Funcionario { } class Gerente : Funcionario { } There a certain moment a Coordinator can become a Manager. How to solve this?…
-
4
votes4
answers144
viewsProblems initializing a type within a LINQ query
I am going through the following problem, I am assembling an API for a forum application and this API needs a endpoint returning a collection of Forum who own the property ParentId nulla. Then I…
-
4
votes1
answer890
viewsIs there a binary tree in . NET?
I don’t know if it’s hidden somewhere and I haven’t seen a binary tree structure on . NET. I searched the documentation of all Collection, including the sublevels and nothing. Don’t have it? Why…
-
4
votes1
answer402
viewsUpdate One to Many Entity Framework
Hello, I need help with an update using Entity framework and relationship one for many. I believe it is something very basic, but I’m starting with EF and I can’t solve the problem. Artist and…
-
4
votes1
answer110
viewsDeserialize Json List
For when the return is only 1 record I use the following: { "id": "27", "name": "Daft Punk", "link": "https://www.deezer.com/artist/27", "share":…
-
4
votes1
answer480
viewsUser registration and password
I have an acceptance problem. After configuring Microsoft.AspNet.WebPages.WebData and the corresponding classes, the system correctly created the tables in the database so that I could implement the…
-
4
votes3
answers614
viewsHow to create a custom list using data from four tables?
I have the following class: Nota { int id; int idFornecedor; int idProduto; int idClasse; } and I have the respective classes for the previous class ids: Fornecedor { int id; string descricao; }…
-
4
votes1
answer1608
viewsProgressbar and Backgroundworker in C#
I’m creating an app with Firebird 2.5 in which I need her to read a file .sql with instructions to popular the database if it has not yet been done this process, because it is a little long and not…
-
4
votes3
answers146
viewsPerformance "Where in foreach vs if"
Which case would perform best? var chaves = new list<string>(); foreach(var item in lista) { if(!string.IsNullOrEmpty(item.Chave)) { chaves.Add(item.Chave); } } Or listaValida = lista.Where(x…
-
4
votes2
answers426
viewsClass relationship - (C# Entityframework)
Hello, I have a Person Class and an Address Class Ex. public class Pessoa { public int Id { get; set; } public string Nome { get; set; } ... public Endereco Endereco { get; set; } } public class…
-
4
votes4
answers156
viewsHow to avoid repetition in LINQ queries?
I have the following query LINQ which is in a method that returns all products: var query = from p in Produtos select new Produto { ProdutoId = p.ProdutoId, Descricao = p.Descricao, Preco = p.Preco,…
-
4
votes2
answers403
viewsHow to filter in LINQ for every X months?
Hello, I would like to know the best way to filter a list of objects using LINQ in C#, I have a list of objects called Measuring, each measurement has a Data property, which is the date that was…
-
4
votes1
answer60
viewsHow to create verification that will validate if Reportviewer is installed?
I need to create a check that will validate the installation of Report Viewer on the user’s machine. If not installed, I need to receive this information to make a treatment present a message to the…
-
4
votes1
answer986
viewsHow to create runtime formulas in C#?
There are many advantages when things change for the better, so were the changes from the Clipper to Delphi and C#, actually only in the visual part. There was in the Clipper a fantastic feature…
-
4
votes1
answer442
viewsHow to simulate the event of typing the % (percentage) symbol when pressing Shift+5?
I was developing a calculator in C#, and started doing the activation part of the buttons through the keyboard. if (e.KeyCode == Keys.Add) { btnsum.PerformClick(); } Using the code above, I already…
-
4
votes1
answer1739
viewsDLL Not found
when running my application, I’m receiving the error warning, informing DAL.dll has not been found. I have no idea what it might be, I’m following a tutorial, these are my first steps with C#. I’m…
-
4
votes1
answer514
viewsSelect data from two tables to display in one column?
Consider the tables for customer registration : Table Person |ID|NOME|TIPO|EMAIL| Table Person Physical |ID|CPF| Person Juridical Table |ID| CNPJ| inscricao_municipal| inscricao_estadual| My goal is…
-
4
votes1
answer1911
views#if DEBUG always runs, even in release mode
I’m trying to use the directive #if for a given method to be executed only after publication (in release mode). The code is something like #if !DEBUG AlgumMetodo(); #endif I’ve also tried to add the…
-
4
votes2
answers118
viewsCan I have more than one Views directory in MVC?
I’m transferring my project to MVC, and I was wondering if there could be more than one folder Views in the project, or if you can load a CSS outside the BundleConfig, have a static page that kind…
-
4
votes1
answer1530
viewsHow to put a background image and make it responsive?
I’m learning C, so I’d like to know how to put a background image (background) and also remove the blue edges. I’m using Visual Studio. Ps: some videos I saw on Youtube were basically about going…
-
4
votes1
answer301
viewsHow to make an element disappear after used?
How to make an element disappear after used for example : When you click on a button it disappears and appears something like a Listbox? Ps1 : If the question is confused warn Ps2 : If you can tell…
-
4
votes1
answer65
viewsHow to calculate the time of a LINQ query?
I have a table with +- 900mil records. I make some queries using clauses where and I want to see the time difference between them. How do I show time in one label at the end of the consultation?…
c#asked 7 years, 4 months ago Italo Rodrigo 4,344 -
4
votes1
answer310
viewsAbstract class and C#properties?
Hello, everyone! Next, I created an abstract class called Tables, where classes of basic tables of the system will inherit from this abstract class. As Neighborhood, City, States, category, etc..…
-
4
votes2
answers1010
views -
4
votes2
answers424
viewsMutiplos projects in MVC and Webapi
I’m looking for if there are any project models that involve multiple MVC and Webapi projects. In the solution I’m thinking about designing (if possible) a content management solution for multiple…