Most anwered "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
votes9
answers2644
viewsBest practice for creating if
Which of the two code options has better performance? I’m going to show you a very simple example, usually there’s more code inside the if. To) string mensagem = "OI"; if(exibirAdeus) mensagem =…
-
71
votes8
answers49747
viewsHow do I remove accents in a string?
I have a string áéíóú That I want to convert to aeiou How do I remove accents? Need to save to database as a URL.
-
35
votes8
answers45010
viewsWhat is the difference between C# and ASP.NET?
What’s the big difference about ASP.Net and C#? I program in C# for desktop, but I can’t understand. C# para desktop (Windows Forms Application) is identical to the C# used in web programming? And…
-
51
votes8
answers2113
viewsIs using customer validation enough?
Using Javascript validations is sufficient for efficient validation? Example: Date validation. It is necessary to check also in the code? What are the disadvantages of only performing validations…
-
8
votes8
answers2805
viewsHow to know which is the last element on a list?
I am doing a dynamic sql query, in which I use lists, my problem is, how to know which last element of this list Follow the code made so far: List<string> campos = new List<string>();…
-
15
votes8
answers2223
viewsError: not all code paths Return a value
I would like to understand why my code is causing the error not all code paths Return a value using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using…
-
19
votes7
answers25439
viewsHow to convert a JSON response to a C#object?
I’m making a request and getting a JSON like this: { "id": "1000000000000000", "name": "BrunoLM", "first_name": "Bruno", "last_name": "X", "link": "http://stackoverflow.com/users/340760/brunolm",…
-
29
votes7
answers9251
viewsIn C#, what is the await keyword for?
I was studying this documentation about Asp.net Identity, and in the examples in C# has a keyword that I don’t know, which is the await, example : [HttpPost] [AllowAnonymous]…
-
58
votes7
answers20675
viewsWhat are lambda Expressions? And what’s the point of using them?
When I started using LINQ I saw I could use the famous lambda Expressions. Until I know that x => x * x is a lambda Expression, but I could not explain to a colleague what they really are, and…
-
13
votes7
answers10092
viewsHow to make child form change values in parent form C#?
I have a register in C#. There is a "street search" button that opens a form search child. When executing the search, displays the result in the datagrid that form son. I would like the event…
-
6
votes7
answers2949
viewsHow to use multiple SQL commands (in the case delete on ORACLE) in one line only on C#?
I made a command because of Foreign Keys, only to plug hole, but it is not working for an invalid character error, I believe it is the ";". I know I’m doing this the wrong way, so I accept…
-
82
votes7
answers21276
viewsBest kind of data to work with money?
I am developing a project for commercial automation, using PAF-ECF and everything else. Would Aual be the best type of data to work with SQL Server and C# for money issues? Mainly in relation to…
-
34
votes7
answers14277
viewsWhat can C++ do that C# can’t?
Being a programmer . Net but with an old passion for C++ (which has grown since C++11), I was with this curiosity. I know . Net can be "extended" with C++/CLI, but I would like to know what C# pure…
-
128
votes7
answers5450
viewsHow to write easy-to-maintain, readable code?
How to know if the code is easy to read and maintain? I usually abstract a large part of my codes, I have a habit of using a lot lambda functions in C#. As this function for CPF validation. public…
-
20
votes7
answers1682
viewsMake the class builder private?
When placing a constructor of a class in C# as private, get the following error: I would like to know the technical explanation for the reason of this error and whether there is any case of use of a…
-
7
votes7
answers1103
viewsRemove part of string until nth occurrence of a character
I have a string that always returns in any of these formats: "0001>0002>0003>0004>0005" "abcdef>ghi>jkl>mnopqr>stuvx" Always has the character > dividing something.…
-
2
votes6
answers6049
viewsHow to make a textbox that updates every time you change the content?
How do you make a textBox that updates in the database the values that are placed in it? That is, the textBox is filled in and the user decides to change what is there and wants it to trigger*…
-
8
votes6
answers1227
viewsProperty readonly . NET
I received this question in a test and could not answer: "How is it possible to declare a property readonly in . NET / C#?"
-
49
votes6
answers32712
viewsAbstract Class X Interface
What is the difference between an abstract class and an interface? I don’t understand when I should use one or the other.
-
1
votes6
answers2938
viewsI can’t get the value of an Asp:hiddenField in c#, it’s always empty
I’m having a strange problem here. I’m assigning value to a asp:hiddenField via javascript (already tested giving alert and it shows the correct value), but then when I try to get its value in C…
-
7
votes6
answers5869
viewsHow to know the number of a week in each month
I am working on ASP MVC4, and would like to know the number of weeks in a given month to generate a list of dates. For example, the user inserts a week, and in that week of each month I will…
-
3
votes6
answers6055
viewsPart of the Label in Bold?
How to place a part of the string of a Label in the Windows Form in bold via code in c#. Someone knows something via code for that?
-
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…
-
14
votes6
answers14419
viewsWhich database should I use in a small desktop application?
I read a bit about the Meta and I thought that this question does not escape much from the current rules of the site. Risking losing reputation, come on: At the moment I work in a small company that…
-
27
votes6
answers8712
viewsHow and when to use Finally after a Try?
First I would like to know why in using the finally What are its advantages? It really only serves for when an exit occurs from within the scope of a block try-catch, as when some return or goto…
-
59
votes6
answers10591
views -
3
votes6
answers15655
viewsClear a datagridview in C#
I tried all this already and nothing has worked. Everyone is deleting the lines and column. What I need is to clear the content written on them. datagridview.datasource=null;…
-
14
votes6
answers2762
viewsHow to walk an Enum?
Here’s what I need to do: string and go through it and pick up each letter found and add with its corresponding value, type: a = 1, s = 19 and etc. Well, I made a enum with all the values of string,…
-
21
votes6
answers502
viewsEmpty semicolon doesn’t make a mistake?
I was working on a project and unintentionally bumped into the semicolon that ended up being inserted well after a if. I was intrigued because Visual Studio did not point out as an error, and when…
-
11
votes6
answers1056
viewsHow to make a Split for when there is a letter in the string?
I’d like to make one string be divided with the .Split() every time there was a letter. Example: To string: 97A96D112A109X115T114H122D118Y128 Would become a array with 9 values: { 97 96 112 109 115…
-
3
votes6
answers6243
viewscheck repeated number inside the array c#
I created a predefined array with some numbers, and I want to know how many repeated numbers there are in the array. but it is only returning the size of the array and not Qtd of repeated numbers.…
c#asked 7 years ago Cezar Mdlosci 85 -
17
votes5
answers2401
viewsHow do I merge two results of a query?
I am developing an application in C# and I would like to know how to put together two results of two darlings SQL in one. I have the following code: public List<MalaDireta> ObterMalaDireta() {…
-
10
votes5
answers2566
viewsIs it recommended to use Linq instead of SQL?
To avoid string abuse and avoid code injection problems can be a good practice using the Linq. I can also imagine, for example, that it’s slower. Who ever used the Linq to communicate with the…
-
57
votes5
answers7848
viewsWhat is the difference of string vs string?
I wonder what the real difference is between String (capital letters) and string (s tiny). Apparently the two have the same goals, but which is "best" to use?
-
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…
-
16
votes5
answers14262
viewsHow to sort list with complex object by one of its properties?
I have a list of objects and I want to sort the list by one of the properties (Desc type string), how do I do this? public class Foo { public string Desc { get; set; } // Várias outras propriedades…
-
74
votes5
answers2194
viewsExceptions consume a lot of processing. Truth or legend?
I’ve seen shows like this : if(!clienteExiste(1)) { return "Cliente não existe."; } and others like that if(!clienteExiste(1)) { throw new Exception("Cliente não existe."); } The second code will…
-
3
votes5
answers1583
viewsHow to get the number of weeks in a date range in C#?
I would like to know how to know the number of weeks in a given date range in C#.
-
2
votes5
answers1056
viewsHow do I connect Windows Phone to an SQL Server?
I’d like to know how to access and receive data from a server from Windows Phone. Put simply: I have a PC and want to access a document directly from the smartphone.
-
15
votes5
answers17754
viewsHow to solve accent problems with ASP.NET MVC?
I’m having problems with accentuation in ASP.NET MVC 5. I am using Visual Studio 2013 Professional and in the application . Net 4.5. SQL Server 2008 and Entity Framework 6. The browser is Google…
c# asp.net-mvc asp.net-mvc-5 entity-framework visual-studio-2013asked 10 years, 11 months ago user3628 -
1
votes5
answers38715
viewsCalling a form and closing a form in the same event
How do I call one form and close a form at the same event. For example: private void iniciar_Click(object sender, EventArgs e) { Close(); Frm1 newForm2 = new Frm1(); newForm2.ShowDialog(); }…
-
-3
votes5
answers2197
viewsHow to create a switch.. case with value ranges?
If a total of days is over 30 and under 60, I do something. If it’s over 60 and under 90 I do something else and so on. How do I do this case? Did the case is the best option?…
-
23
votes5
answers573
viewsWhy are you wearing shorts?
The guy short corresponds to a 16-bit integer - it is literally syntactic sugar for type Int16. The current processors are all 64 bits, even on the most machines low-end. Some older machines still…
-
43
votes5
answers2270
viewsUsing unused affect performance?
While I was developing, I saw that in most of my classes contained a certain amount of using that were not being used and came to me the doubt of the title. Using unused affects the performance of…
-
3
votes5
answers1054
viewsContains in Class List
I have my class, which has 2 classes within it. public class ProfEsp { public Especilidade Especialidade {get;set;} public Profissional Profissional {get;set;} } public class Especialidade { public…
-
21
votes5
answers6769
viewsShould I use GUID or int as the primary key?
I’m about to start a new project in MVC 4 with Entity Framework, searching I found several examples here in Sopt of models that use GUID as ID and some doubts have arisen me: What is the advantage…
-
1
votes5
answers13026
viewsCoin style in a Textbox in Winforms
I need to put the text R$ in a textbox so that it has the following format: R$: 1,200.58 I am trying in the following ways without success: textbox1.Text =…
-
7
votes5
answers9265
viewsSearch judicial process data on the TJSP website
I am developing an ASP.NET application with C# that will need to consult the proceedings of online lawsuits. So far the only way I could find to get this information was to do the direct…
-
7
votes5
answers1506
viewsRead XML file in C#
I’m having a problem reading an XML file in C#. In which this is a file of a pre-sale, and I am with the following situation: in my xml I will have several pre-sales, and each pre-sale may have…
-
4
votes5
answers6761
viewsHow to create composite key with Entity Framework 6
I have my model base that all classes inherit from it: public class Base { public int Id {get;set;} public int ClienteId {get;set;} } And an example of model: public class Grupo: Base { public…