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
-
12
votes2
answers1715
viewsBack previous position in Visual Studio
When we want to see some method, we press F12 and then we are "transported" to the said method. It turns out that this method can be in another project or other form or in one user control etc and…
-
12
votes1
answer225
viewsDoes the name size of a variable affect your weight?
There’s a size difference between that: string packet1234 = "123"; And that? string packert1234556 = "123";
-
12
votes2
answers732
viewsHow to leave an invisible Tabpage inside a Tabcontrol?
How can I leave a certain invisible Tabpage inside a Tabcontrol ?
-
12
votes2
answers1480
viewsHow to edit a list in C#?
I want to edit a record of a client in which I can already register, consult and remove. But I have no idea how to edit just a few items without others being lost. class Program { static…
-
12
votes4
answers7973
views -
12
votes1
answer6642
viewsWhat is a memory dump?
What is a dump from memory? How it can help in the possible identification of an inconsistency in the code? How the analysis is performed?
-
12
votes3
answers3072
viewsHow to convert a string to List<int>
I have the following variable and would like to convert it to an integer list: string variavel = "1,2,3"; How to convert it to a list of integers?
-
12
votes3
answers14451
viewsTurn the first letter of a string into uppercase?
Example: I have a string "stack exchange", how do I transform your first character, getting "Stack exchange"?
-
12
votes4
answers1580
viewsIs this a common practice in object orientation?
In object orientation, one way to ensure encapsulation is to maintain the attributes of the private classes and modify their state via methods. In addition, to ensure the integrity of objects, it is…
-
12
votes1
answer3277
viewsHow does the Linq Aggregate() extension method work?
I just saw some examples that used the method Aggregate() of namespace System.Linq, but I couldn’t find any good explanation for how to use it. What does this method and how it should be used?…
-
12
votes4
answers595
viewsHow to create a variable where to access its properties via string?
I’d like to access by string the properties of an object: (EXAMPLE 1) var cor = casa["cor"]; var tamanho = casa["tamanho"]; Instead of accessing like this: (EXAMPLE 2) var cor = casa.cor; var…
-
12
votes2
answers10649
viewsCheck if a word is within a sentence
There is how I check if a word is within a phrase described by the user? Ex: palavra = "criativo"; Phrase written by the user: "Eu sou criativo"…
-
12
votes1
answer6870
viewsDate problem with globalize.js and jquery.validation.globalize.js. How to resolve?
I’m having problems with the date fields of my application. Follow this answer that seemed more appropriate, Datetime field error message, I configured my ASP.NET MVC application as follows: I…
-
12
votes3
answers7644
viewsHow to create a Datetime object that represents the last day of a given month?
On an object of the type DateTime, how do I get a new object object DateTime representing the last day of the month of the first object? var data = new Date(2017, 3, 1); // 01/03/2017 var…
-
12
votes2
answers381
viewsJava 8 "default method" versus C# "extend method"
Java 8 introduces the concept of "standard method" to allow adding new features to an interface. C# provides "extension methods" that allow "adding" methods(features) to existing types. Taking into…
-
12
votes2
answers437
viewsPerformance difference of Any() and Count()
When I need to check whether a Collection has or has not elements which of the two methods will be faster, .Count() =! 0 or .Any()? I’ve heard that the .Count() may be faster in some cases. But by…
-
12
votes2
answers489
viewsHow to organize the code to be reused
Consider the following scenario: As you can see, Prefab (red) consists of 3 elements: The sprite (which is the ground, the brown squares and the green tube) The enemy (pink) which is another Prefab…
-
12
votes2
answers141
viewsDynamic declaration in attribute property
As part of a microplataforma ORM I’m developing, I’m defining a generic class that implements exclusively tight Coupling (1 record x 1 object). public class Course : MicroEntity<Course> {…
-
12
votes2
answers1960
viewsEmpty delegate ( delegate { } )
What returns the instruction delegate { }? Would be an empty delegate? In which situations would it be necessary to create an empty delegate?
-
12
votes4
answers750
viewsHow to limit the resources used by the system?
I have a loop loop that makes several iterations and has in its scope calculations that require a lot of processing. The problem is that when executing the code snippet, the use of the processor…
-
12
votes2
answers785
viewsSelectize.js with Tags, reload key and value in edit form
I posted the same question in the Gringo OS too. I’m making a research form (action=GET) where a field uses Selectize.js: $("#selectize").each(function () { $(this).selectize({ plugins:…
-
12
votes1
answer751
viewsWhat is the method group?
Coding in C# I ended up making a mistake, perhaps by familiarity with other languages that I usually work, and forgot the parentheses. string.Concat(numero.ToString, "A") I got the following…
-
12
votes2
answers815
viewsHow does the logic of Where in the Entity Framework work?
I’m studying C# and I just made my first query in the Database: using System; using System.Data.Entity.Core; using System.ComponentModel.DataAnnotations; using…
-
12
votes3
answers172
viewsWhat is the difference in the 3 types of variables and how do they behave in the compiler?
For test questions, I made the following code: static int valor1 = 10 / 5; static int valor2() => 10 / 5; static int valor3 => 10 / 5; public static void Main() {…
-
12
votes3
answers5129
viewsWhat is the difference between using single and double quotes in C#?
In PHP, when we use single quotes or double quotes, both forms have the functionality to declare a string. There is only one small difference. I am now starting a study with C#. When I went to try…
-
12
votes1
answer208
viewsIs there any error suppression mechanism in C# similar to the PHP arroba?
I’m studying C#, but I’m used to programming in PHP. I know that in PHP it is possible to delete some error messages by putting the @ (arroba) at the beginning of the expression. For example, if I…
-
12
votes2
answers1470
viewsWhat are the pointers?
I’ve come across this in several languages, mainly C and C++, but I’ve never understood what it is, how it’s used, and why it exists. I found out unintentionally that it also exists in C# and it’s a…
-
12
votes4
answers549
viewsProblem with polymorphism
I have a polymorphism problem. But before I explain it, I want to make it clear that I’m still learning a lot, so if you want to throw my structure in the garbage, be my guest. I have a project that…
-
12
votes2
answers688
viewsClass copy in C#
In C++ programming to copy one class, to another, just do the following: minhaClasse* class_1 = new minhaClasse(); minhaClasse* class_2 = new minhaClasse(); *class_2 = *class_1; // Faz a atribução…
-
12
votes5
answers5490
viewsCount the number of months between one date and another
I would like your help to basically count the amount of months between a date and another. I’ll give you an example but what I want is basically just an accountant. Ex: quantity of months between…
-
12
votes2
answers675
viewsSum of Timespan in C#?
In the sum of two variables of the type Timespan with the language c# I was able to observe that it happens as if it were a mathematical operation of two simple numbers, example: TimeSpan t1 =…
-
12
votes1
answer293
viewsWhat are the best practices with implementation of Dryioc, Fluentvalidation and Lazy?
I’m building an architecture based on the use of Lazy, DryIoc e o FluentValidation. I intend to do all validations with the object. When actually using the object I will instantiate it (Start). I…
-
12
votes4
answers316
viewsIs it bad practice to make this comparison?
To compare two values with a single one, I can do as in the example: if(foo == "abc" || foo == "54") { ... } But as I need to add more conditions, it starts to get complicated: if(foo == "abc" ||…
-
12
votes5
answers3081
viewsHow to decide between using for or foreach?
When should I choose between using the for or foreach? They both do pretty much the same thing, and I always wonder if I’m using the "correct"... My doubt increases when people say to use the for…
-
12
votes1
answer449
viewsWhat’s this 'in' in C#?
In the new version of C#, version 7.3 the parameter changer was introduced in, but I didn’t understand its functionality. By name, it seems that it is used as "input" for the values, contrary to the…
-
12
votes1
answer294
viewsMandatory language incorporating functional elements
Yesterday I was reading an answer about the differences between the paradigms functional and imperative, and I came across this statement: Functional Programming and Object-Oriented Programming.…
c# characteristic-language functional-programming paradigms imperative-programmingasked 6 years, 2 months ago Pedro Gaspar 3,289 -
12
votes1
answer1392
viewsWhy, in C, does a function need to be declared before it is used?
This question was asked on Facebook. Lé is a problem because there is no room for a good answer, there is no way to classify the answers as to their quality properly, much appreciated by the…
-
12
votes2
answers348
viewsShould or should not Httpclient be used within a using block?
Reading this reply, a question relating to the use of using, I was curious about the following statement: In fact everyone uses HttpClient wrong, I even used and did not know everything, because I…
-
11
votes1
answer286
viewsWPF form is going behind all windows when a Combobox is selected
My form WPF works perfectly, but in a ComboBox specific, after the action of selecting, the form is going behind all the windows, without further explanation, and this does not happen in any other…
-
11
votes1
answer5272
viewsWhat is a wrapper class?
What is a wrapper class? How they can be useful? Cite examples of use in php or c#, as well as when to use or not to.…
-
11
votes5
answers2480
viewsCheck if day exists in month
I need to verify/validate if a (numerical) day exists in a given month. For example, I have the day 31, and as it does not exist in the month of February the condition will fail. I think a simple if…
-
11
votes6
answers11946
viewsConverting a string to int?
How best to convert a variable string for another variable of the type int?, namely, a nullable of int? Performance is very important in this case because I will be converting several values within…
-
11
votes2
answers677
viewsWhat is the difference between typeof(T) vs. Object.Gettype()
What’s the difference? Is there any difference between performance?
-
11
votes2
answers1153
viewsConsulta Lambda
I have the following consultation at T-SQL: SELECT TOP (60) COUNT(*) AS QTD, SUM(Duration) AS Total, AVG(Duration) AS Media, MIN(Duration) AS Menor, LEFT (TextData, 80) AS TextData FROM Traces WITH…
-
11
votes2
answers483
viewsASP.NET Identity and Windows Identity Foundation (WIF)?
Once again talking about ASP.NET Identity. There is another theme within this same subject that I believe is of great importance to the community (mainly to me, the main interested). This is the…
-
11
votes4
answers2950
viewsDraw where the name cannot be drawn more than once
I need to make a simple drawing software, but I don’t know how to take the names that were entered in the list box and draw one among them. The same name cannot be drawn more than once. How to do…
-
11
votes3
answers1211
viewsConcepts of Mesomorphic Allocation and Liberation in C#
I’m making a web application that has a finite recursive loop. But during the process the memory consumption is constantly growing and at the end Visual Studio has more than 2 Gigas of memory use. I…
-
11
votes2
answers197
viewsNomenclature or language in lambda
We have that expression: var teste = meucotexto.minhatable.Where(x => x.meu_campo.....) How I read that part x => x.meu_campo Leio x is for x.meu_campo or x of x.meu_campo or something else?…
-
11
votes3
answers175
viewsWhat is the most correct way to make a query with LINQ?
I am trying to make a LINQ query in my BD SQL Server, but the result of it always comes 'null'. I need the first user ID I query. This is the way I try to consult: public decimal…
-
11
votes1
answer800
viewsBuild complex Lambda Expression
I’m trying to build a Lambda Expression that’s a little complex and I’m having difficulties. The goal is this expression: items = items.Where(x => sValues.Any(y => x.Contract_Rates.Select(z…