Most viewed ".net" questions
The Microsoft . NET is a set of libraries and functions that are part of the Basic Class Library (BCL), such as user interface functions, data access, connectivity, cryptography, web development, mathematical algorithms, and network communication.
Learn more…2,689 questions
Sort by count of
-
10
votes2
answers73740
viewsHow to access the print screen image?
When we hit the button Print Screen from our keyboard, the screen image is saved in some cache, in memory, somewhere, because when we give Ctrl V after, in Paint for example it trims, how to access…
-
22
votes3
answers57329
viewsFormat double with mile and decimal
I have the following value: 43239.110000000001 I used this command: txtSomatorio.Text = String.Format( "{0:#.#,##}", somatorio); I got this: 43239,11 How to do to display like this? 43.239,11…
-
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.
-
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(); }…
-
14
votes3
answers30199
viewsHow do I round numbers to the nearest integer?
I have numbers double as double a = 0.4, b = 0.5; How do I round it up?
-
5
votes5
answers29254
viewsHow to convert date to dd/MM/yyyy format?
After I published my app, I started to receive the dates in the American format like this:9/14/2016 12:00:00 AM How to format to dd/MM/yyyy? I tried to convert.ToDateTime() more does not work.…
-
31
votes4
answers28968
viewsWhat is the most appropriate way to concatenate strings?
There are different methods for concatenating strings, such as Concatenating with the operator "abc" + str Formatting String.Format("abc{0}", str); Using the Stringbuilder new…
-
20
votes2
answers25606
viewsWhat kind of data (double, float or decimal) should I use to represent currency in . NET with C#?
Although I am aware of what would be better to use, I ask this question for educational purposes since I see several examples of people using double in C#. But I’ve had problems with double for coin…
-
11
votes4
answers25519
viewsThe input character string was not in an incorrect format. Operators
Hello, I’m beginner in programming and I’m trying to show the user how much RAM is being consumed at the moment, I’m using the following code that is not pointing nor an error when compiling only…
-
9
votes1
answer22992
viewsAccess Mysql with C#
I’m creating a Form simple that has 3 TextBoxes and 3 buttons and I want to save the information typed in Textboxes in a table. I’ve already created the querys all within a class acessoBD, but I…
-
6
votes3
answers20560
viewsPick first and last name and abbreviate middle names only with the initial
I would like to address the following string: string nome = "Rafael Rodrigues Arruda de Oliveira" With the following criteria:: Keep first and last name; Abbreviate the other names (middle names)…
-
10
votes2
answers19497
viewsHow to get a snippet of a string?
I have a string like this: ~/Areas/Teste/Views/home/index.cshtml I just need the word that comes right after ~/Areas/, in the case Teste (remembering that this word may vary in size). How do?…
-
68
votes1
answer19312
views -
5
votes3
answers19154
viewsHow to take the path of the open executable in C#
How do I take the path of the project in c#? Is there any function? Or I have to write the full path on my application?
-
11
votes3
answers17994
viewsWhat is the Difference Between HTML.Actionlink vs Url.Action?
Reading some tutorials of ASP.NET MVC I found these two helpers being used to do basically the same thing, which was to direct the user to a new view. So I wonder if there’s any more remarkable…
-
54
votes4
answers17728
viewsWhat is a scaffold?
I started studying ASP.NET MVC and came across the term scaffold, but I didn’t understand it very well, so: What is scaffold? What is its use within ASP.NET MVC?…
-
13
votes3
answers17303
viewsWhat is the best way to read an XLS file?
I would like to know the best way to read an XLS file in C#. I can handle it the same way I handle a database table?
-
3
votes2
answers16833
viewsHow to obtain only the date, without the time, of a Datetime?
Converting a field using ToDateTime it brings the date and time. parcelamento.data_vencimento = Convert.ToDateTime(reader["data_vencimento"]); Is there any direct conversion to bring only the date…
-
68
votes2
answers16758
views -
28
votes2
answers16435
viewsWhat are the out and ref parameters
What is the use of parameter types ref and out of a method in C#? What is the difference between the two? Some example of each one’s use.
-
12
votes3
answers16084
views -
10
votes2
answers16045
viewsForeach or lambda in lists
Which one do I get the best performance to get the value of a given in a list? I do foreach or lambda(when possible, of course)? I can have this: foreach(var i in lista) { var teste = i.NmCampo; }…
-
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"?
-
11
votes2
answers14331
viewsHow does Groupby work on LINQ?
I’m having trouble understanding the operator Groupby on LINQ.
-
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…
-
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…
-
49
votes1
answer13752
viewsDifference between Icollection, Ilist and List?
What’s the difference between ICollection, IList and List? When I should use each one specifically?
-
1
votes1
answer13532
viewsC# Select and display in a combobox
I’m creating an application in C# windows Form and wanted to know how to select a table and display a list of clients in a combobox.
-
14
votes3
answers13485
viewsChange the Datetime Timezone.
I am hosting my system on a server that is in the USA. So when using the DateTime.Now returns the date and time of the US. I would like you to return the date and time of Brazil. It is possible?…
-
6
votes3
answers13362
viewsHow to remove whitespace from a text?
I was trying to get blanks out of a string, but the .Trim() does not work, it displays the white spaces yet: var teste = texto.Trim(); txtConteudo.Text = teste; For example, if he receives: "text ",…
-
4
votes4
answers13213
viewsTextbox accept numbers and commas
I need that one textBox accept only numbers and commas. To accept numbers I’m doing so: private void textbox11_num(object sender, KeyPressEventArgs e) { if (!char.IsDigit(e.KeyChar)) { e.Handled =…
-
29
votes2
answers12489
views -
28
votes2
answers12475
viewsWhat is the Antiforgerytoken?
What is the AntiForgeryToken and what it serves as in an ASP.NET MVC application?
-
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…
-
7
votes3
answers11852
viewsHow to separate a String according to a separator in C#?
I have a string in this format: string valores = "Numero1#Numero2#Numero3#Numero4#"; How do I tell it in an array of integers to get it: int Numero[1] = Numero1; int Numero[2] = Numero2; int…
-
79
votes2
answers11641
viewsWhat is Reflection. Why is it useful?
It is recommended to use in projects? How to use? In what situations Reflection can be used?
-
48
votes3
answers11626
viewsWhat’s the use of the reserved word "Yield"?
What is the use of the keyword (reserved) yield? When and where it is used?
-
3
votes4
answers11622
viewsIs it possible for a Javascript function to call a method that is in the Behind code of the page?
I have a button and I wanted to program the click of it, and when I wear a <asp:Button> I program the click of him in the code Behind. Now I’m wearing a button normal. I know almost nothing…
-
2
votes2
answers11603
viewsHow to break lines (console mode)?
How I break lines in C#, as if I put two commands Write the console will print them side by side, as I do to print on the bottom line. Ps: Code below var A1 = Console.ReadLine(); var A2 =…
-
22
votes3
answers11209
viewsDifference between Any, Contains and Exists
What’s the difference between Any, Contains and Exists? What is the appropriate context for each of them? (Examples of use) What are the advantages and disadvantages?…
-
10
votes3
answers11142
viewsDifference between Console.Read(); and Console.Readline();
I’m starting to learn C# and I got a little confused by one thing. What’s the real difference between Console.Read(); and Console.ReadLine(); ?
-
17
votes1
answer11086
viewsHow to check the execution time of a method?
Example: I have the Metodo1 and the Metodo2 both have different processing and actions. I want to check how long each takes to run. How do I do that?
-
8
votes1
answer11054
viewsStreamwriter Special Characters with Encoding.ASCII C#
I am writing in a file via Streamwriter using the encoding Encoding.ASCII. A situation has appeared where I need to write the letter "Ç". Only if I try to do that, the file leaves the character "?".…
-
22
votes3
answers10939
viewsHow does the C#lock work?
I was just looking at an article by MSDN, but it was not clear why to use this. class Account { decimal balance; private Object thisLock = new Object(); public void Withdraw(decimal amount) { lock…
-
18
votes2
answers10850
viewsWhat is the main difference between int. Parse() and Convert.Toint32()?
In C#, there are two ways (among others) to convert other types to int: Convert.ToInt32(valor) and Int32.Parse(valor). What is the main difference between these two forms of conversion?…
-
16
votes1
answer10829
viewsHow to make the app wait for a while?
It is common to have situations that we need to delay the execution of the code for a period, whether to show or delete a message or something visual shortly after, or to try something again, to…
-
1
votes2
answers10665
viewsHow to get time difference between two Datetime variables in C#
I have two variables DateTime, which are Datacadastro and DataAtual(DateTime.Now). I need to know if the time difference between these two dates is greater than or equal to 4 hours. Is there any…
-
59
votes6
answers10591
views -
5
votes3
answers10165
viewsRemove non-numeric characters from a string
Example: I have the following string "M1245D454" and I need to just leave the numbers on it. M and D are examples, I want to remove any non-numeric character. There is some function in C# or VB.NET…
-
3
votes1
answer9941
viewsReturning difference between days and months
I am developing a C# function that calculates the interest applied to a given account. for this it is necessary to know the correct difference between days and months. How is it possible to execute…