Most voted ".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
-
4
votes1
answer157
viewsLibrary equal to C# 6.0 runtime Interpolation string
Does anyone know of a library that interpolates at runtime on strings? I know it could be done using Replace(), but I don’t want to pass the list with all the variables. For example: Programa de…
-
4
votes2
answers605
viewsField format for saving time
Which field should I use in SQL Server to save a duration? Ex.: 2days 23H 47min 00Sec. If you have an example with Fluent API it will help a lot.
-
4
votes1
answer87
views -
4
votes1
answer337
viewsHow to declare an integer type variable in C#?
I’m learning C# to migrate a system in VBA to C#. I’m really enjoying the language . NET. How do I declare an integer type variable?
-
4
votes2
answers216
viewsView Model should have related classes?
I have three entities: Manager, PersonalData and Address. A Manager has a PersonalData and a PersonalData has a Address. My doubt lies in the time to create the Viewmodels, I would have to have…
-
4
votes2
answers1008
viewsRedeem code from an executable program?
I created a program to present in high school, but due to problems on my hard drive, I lost his code and only have the executable that I created to present it. Unfortunately, I also need the code…
-
4
votes4
answers447
viewsC# Textbox to stop receiving after comma
I need a textbox to stop receiving values after the comma, once it reaches 2 houses. To simplify, think that the text has limit after the comma, but none before it. Example: Type the number 2.99.…
-
4
votes2
answers3495
viewsDevelop in C# and . NET on Ubuntu Linux?
Recently I had to migrate from Windows to Linux, because my work notebook burned and I am using an old one with Intel Atom and only 2GB of RAM, I was insecure to use Windows because it is a very…
-
4
votes1
answer571
viewsIs there a difference between C++ from GCC and C++ from Visual Studio?
I already programmed in C++ compiling with GCC and when I started using Visual Studio I noticed that it has support for C++, but the implementation is aimed at the platform . Net. There is a…
-
4
votes3
answers932
viewsError comparing numbers and checking if they are equal
I’m doing a simple C# exercise in which I have to receive two numbers, compare them and print out which is the largest or whether they are equal. When I start the program, I can only put the first…
-
4
votes1
answer263
viewsPassing model via dynamic form parameter in . NET MVC
I created this function to generate a handle (or slug, how to prefer) for the model users, the problem is that I would like to make it more "modular", so that I can easily implement in any other…
-
4
votes1
answer256
viewsWhat is the difference between "Exception.Message" and "Exception.Tostring()"?
I’ve read some answers regarding try-catch and on the Exceptionbut I still have doubt about the difference in Exception.Message and Exception.ToString(): What’s the difference between one and the…
-
4
votes3
answers763
viewsI need to validate a TXT layout in C#
I have a TXT file where I need to validate the number of characters of each column according to the layout of each document. Note: Documents are all in one file *.txt In the second column is the…
-
4
votes1
answer79
viewsIs using "Touint64()" to format string correct?
Looking for a practical way to format string I came across the following: Convert.ToUInt64(string).ToString(@"00000\-000"). It is a good pathic to use this method to format strings? There is a…
-
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 =…
-
4
votes2
answers2610
viewsDate and time validation
How do I make so that in the date field, is not saved a date that has already passed, for example yesterday and in the time field is not typed an invalid time, for example 27:00, only the Brazilian…
-
4
votes4
answers188
viewsSQL Embedded in C#
I have a C# application that uses a Mysql database with Entity Framework. However, the size of the database is ridiculously small, so I don’t think it’s worth having a Mysql database server just to…
-
4
votes1
answer76
viewsIs it possible to delete "C:" using Directory.Delete?
Using Directory.Delete("C:", true) deletes partition? Or it is just locked and does not run?
-
4
votes2
answers842
viewsUsing Array.Foreach to modify the collection
I want to remove spaces from the beginning and end of the string (Trim) in all positions of array, but none of the ways below worked. What am I doing wrong? var optionArray = new string[] { "in the…
-
4
votes2
answers310
viewsWhich object performs best? Sqldatasource or Datatable?
In terms of performance, speed, or even safety, what is the best object to be used as a DataSource? Example, I’m creating a DataSource, to popular a GridView: For SqlDataSource:…
-
4
votes2
answers358
viewsKeep variable in memory until system reboot
There is a way to keep a variable in the memory of the machine until it restarts? My application made a change in the system and sent the message to the user to restart the machine, to prevent any…
-
4
votes1
answer74
viewsIs there Smtpclient.Timeout with infinite value?
Is there any way to put SmtpClient.Timeout with the infinite value? If so, how?
-
4
votes3
answers2680
viewsHow to iterate over a dictionary?
I have seen several ways to iterate over a dictionary. There is one considered standard?
-
4
votes1
answer3294
viewsInvalid postback or callback argument
I’m having a mistake that came to nothing, I’m two days trying a solution to the same and so far unsuccessful. I have a form all made in webforms that when clicking the button to send the data is…
-
4
votes1
answer1658
viewsIssues with accentuation when reading data from JSON file
The method below is extracting data from a JSON file, to fill a Dropdownlist. public static List<Uf> GetAll() { var client = new WebClient(); JsonSerializerSettings settings = new…
-
4
votes2
answers175
viewsShould I make sure the threads end at Dispose?
There are already some questions about the interface IDisposable and the using, for example: What types of resources are released in a statement using I should always use Disposis Still I’m not sure…
-
4
votes1
answer151
viewsProblem with null variable
I’m developing software in C# with MVVM model, and with Visual Studio. It is a software to manage the members of a university. We must also use a database, with Code First. My problem is it gives me…
-
4
votes1
answer66
viewsWhy can’t we use Await inside a Catch, Finally and Synclock in VB?
Why can’t we use the operator Await within the statements Catch, Finally and Synclock in VB? The C# 6.0 has support to use the Await within the Catch/Finally.…
.net vb.net characteristic-language try-catch asynchronousasked 7 years, 9 months ago vinibrsl 19,711 -
4
votes1
answer109
viewsRandom Order with Entity Framework
I would like to translate the following SQL statement to an expression lambda: SELECT TOP 1 * FROM tbPessoa order by NEWID() What do I put in OrderBy that will be accepted? var pessoa =…
-
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
votes1
answer266
viewsSave dataset C#
I’m searching several tables from the database for a Dataset through a Stored Procedure in the MySQL using the Mysql Workbrenck, but when saving only the first table is saved, my code: Stored…
-
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
answer2349
viewsWhat is the reference to Httpcontext.Getowincontext() ?
I had to abstract the Controllers of an application ASP.NET MVC for a Class Library because I’m using different technologies in the same application. However, I have the error:…
-
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
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
answer373
viewsDual cryptography
A colleague told me that he created an encryption class that implements 4 algorithms: Tripledescryptoserviceprovider Class Descryptoserviceprovider Class Rc2cryptoserviceprovider Class…
-
4
votes1
answer44
viewsIs it possible to restrict who can use the public classes of an Assembly?
The scenario is as follows: I have a AssemblyProtegido.dll written in . NET that contains public classes. I wish only specific assemblies could consume such classes. Assemplyprotegido.csproj public…
-
4
votes2
answers220
viewsHow to map and obtain only one property or field of a query?
I’m using the Dapper that has the purpose of map properties of objects. See a practical example: var servico = conexao.Query<Servico>(statement.ToSql(), new { IdServico = id }).First(); That…
-
4
votes1
answer220
viewsDevelop Windows 10 and Windows 8 compatible application
I am working on an application that we use Windows Forms to develop its alpha version. Soon, we will start developing a more stable version of this system, and, it was then that the support…
-
4
votes2
answers1511
viewsCipher de Vigenere
private static void algoritmo(String input, String chave, Boolean b) { Console.WriteLine("Digite a mensagem: "); input = Console.ReadLine(); Console.WriteLine("Digite a chave: "); chave =…
-
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
answer1187
viewsWhat is marshalling and how does it work?
I’ve been working with a device that I sent to my software some information, but this information came in the type IntPtr, to read them, I had to use the class Marshal of . NET. What is marshalling…
-
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
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
answer2601
viewsWhat is the difference between Show(), Showdialog() and Application.Run()?
I read something about modal but did not understand, someone could explain?
-
4
votes3
answers351
viewsGroup by days interval using Linq
How can I use interval grouping with Linq? var dados = new[] { new { Id = 0, dias=100, preco= 25, Nome="etc"}, new { Id = 1, dias=40, preco= 50, Nome="etc1"}, new { Id = 2, dias=50, preco= 55,…
-
4
votes2
answers287
viewsHow to add methods to a native class?
How to add functions in a native C#class, in my case I tried to do in System.Math only as a test: public class Math { public static double test(double a) { return a; } } And call it that:…
-
4
votes2
answers227
viewsRemove "OR" condition from LINQ query
I have the following method: bool naoUsarNomeCliente = String.IsNullOrWhiteSpace(filtro.NomeCliente); long codigoExterno; bool naoUsarCodigoExterno = !long.TryParse(filtro.CodigoExterno, out…
-
4
votes1
answer79
viewsA list of a guy can’t pass as a list of his 'higher' type?
There are some entities in the application that I am developing that need to be sorted by a predefined routine. Thinking about it was created contract class, called ElementoOrdenavel and all…