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
answer386
viewsIs it possible for a program to modify its own code?
I was developing an artificial intelligence program with neural networks, but what always left me chained is that every time I open the program, it will have to repeat the entire learning path to…
-
4
votes2
answers233
viewsWhen I type broken number, it removes the comma and sums as integer
static void Main(string[] args) { Console.Write("Digite sua primeira nota: "); double n1 = Convert.ToDouble(Console.ReadLine()); Console.Write("Digite sua segunda nota: "); …
-
4
votes1
answer682
viewsMaking the Insert in SQL Server in a float field?
I have the following problem in my code, I have a textbox that receives the value 0.900, only when I’m recording this value in the bank, it’s only recording 900, and I need you to record the 0.900…
-
4
votes3
answers388
viewsIs it possible to offer return options in a method?
As far as I know Overload in the creation of methods, which are execution options, example(very simple), a method where you have the option to pass 2 or 3 parameters calling the same function:…
-
4
votes1
answer1477
viewsWhat exactly does the Application.Doevents() method do?
According to the help of Microsoft, the method Application.Doevents(): Processes all Windows messages that are currently in the message queue. But what does that mean? Why does he say messages? What…
-
4
votes2
answers872
viewsWhat are anonymous methods and what is their main purpose?
I know they’re used to working together with delegates, but the sources I found were a little confused in my opinion.
-
4
votes2
answers624
viewsWhen using optional parameters above overloading and vice versa?
An optional parameter in C# is declared as follows (see parameter y): public void DoFoo(String x, String y = "") { ... } In many cases, this Feature can be replaced by Overload signature of the…
-
4
votes2
answers455
viewsHow to fix this error "Cannot Convert from 'int' to 'char[]'
Why is this error presented? I believe the logic is right.…
-
4
votes1
answer126
viewsStack/Stack with priority in c#?
My teacher passed 2 exercises, the first was to create a stack (Stack) simple to run unit tests in this class: using System; using System.Collections.Generic; using System.Linq; using System.Text;…
-
4
votes1
answer407
viewsJavascript Alert Does not work on Firefox and Chrome
I’m trying to generate a wrong password alert in Javascript. It’s for a web application that works on .net. This alert works on IE, but we are porting the system and wanted it to work on both IE and…
-
4
votes2
answers401
viewsSimultaneous calls in Restful service
Hello, I’m having doubts on how to make fun simultaneous calls (about 100) in a REST service. The example of code I have is the following: using (var http = new HttpClient { BaseAddress = new…
-
4
votes2
answers91
viewsChecking whether data persisted successfully
What would be the best way to get one bool indicating whether the method Add() and then SaveChanges() was successfully performed? Am I trying like this? Is that right? public bool…
-
4
votes1
answer95
viewsString Contains Empty returns true
Why when using the Contains("") in a string not empty returns true? Example if ("MinhaString".Contains("")) { Console.WriteLine("String contém vazio"); }…
-
4
votes2
answers677
viewsIs it mandatory to open and close connection when entering data?
In a *loop* que fazInsert` in an Excel spreadsheet it is mandatory to open and close the connection ? I analyzed the following, depending on the amount of registration it may take up to 1:30 to do…
-
4
votes3
answers857
viewsDollar next to number in Tostring format
When I try to format a value using .ToString("c2") do . NET the symbol of the coin comes stuck with the number. This makes the formatting ugly and wrong to my point of view. Example:…
-
4
votes5
answers212
viewsGet array object by description in index
It is possible to use the property of an object as an index of a array, as described in the example below? using System; public class Program { public static void Main() { var myObjectArray = new…
-
4
votes1
answer166
viewsIf I have two servers (application and database) with different time zones, which one is better to use as a base?
I am working with the Mysql server of a hosting, I can not change the time zone of the same, I mean it uses the "Mountain Standard time (MST)", on the other hand, I am using the ASP.NET server and I…
-
4
votes3
answers973
viewsWebsocket - c# . NET
I found almost nothing about Websockets + . NET on google, I would like to know how this server is made using the . NET in the future the idea is to create an application and hardware (Arduino) that…
-
4
votes2
answers192
viewsWhy is there no String.Toint() method?
String in C# is an object, right? From what I saw to string is a class, different from int and other primitive types that are simple types, (I’ve seen on another site too, that they are all objects…
-
4
votes4
answers2605
viewsBreakpoint in visual studio does not load at debug
I have a solution with 3 projects, one of them being Ex.utils and Ex.Api. Where the . dll of the utils project is referenced in Ex.Api in 'References'. Both compiled in the same version of . NET.…
-
4
votes1
answer101
views -
4
votes2
answers132
viewsSHA512 hexadecimal return
I found an example of encrypting a string with SHA512. public static string HashedString(string text) { SHA512Managed sha512 = new SHA512Managed(); byte[] hash =…
-
4
votes1
answer92
viewsHow can Stack expressions handle stack variables?
I’m learning C# and I’m reading about Brazilian expressions. The question is: how does it work and why does it work? public delegate void Test(); public void Foobar(ref Test del) { int var = 10; del…
-
4
votes1
answer80
viewsFormat the Array view in C#?
I have a string array. string[] nomes = { "Maria", "João", "Francisco", "José", "Antonio", "Osvaldo", "Francimar", "Cirineu" }; I would like to display them exactly like this on the Console Maria…
-
4
votes1
answer241
viewsWhat is the advantage of using the latest version of . NET Framework?
By default my Visual Studio selects . NET Framework 4.6.1 when starting a new project, but is there any advantage in selecting the latest version? (4.7.1)
-
4
votes1
answer533
viewsWhat is the difference between Task and async Task?
In the code below I wrote two methods, one with the return Task and another async Task. What happens differently in the execution of these methods since for one added in the construction the…
-
4
votes3
answers103
viewsNullable property in C#
I was looking at some tutorials and suddenly I saw this property public Nullable<int> Id {get; set;}. What it means and when I would use it?
-
4
votes1
answer150
viewsHow to implement an abstract method with a generic class in C#
I am creating a functional Factory where I define what is its output type and what are the required implementation methods. With this implementation, when I try to use the object obj within the…
-
4
votes1
answer1109
viewsHow to change the color of the progress bar?
I’d like to do two things on my progress bar. Change color from green to red. Remove the blocks and create a color. I’m using Visual Studio Community 2019 on Windows 10.…
-
4
votes2
answers145
viewsHow to leave the background of Visual Studio 2008 in dark theme?
I use Visual Studio 2019 and love the dark theme, but lately I’m using 2008 for work demands and it has the white theme. It is possible to put it in the dark theme ?
-
4
votes2
answers2190
viewsConvert string to float on C#
What I’ve learned so far when we want to use the command Console.Readline() to read data that the user type we have to perform a conversion when this data is not of the type string, I know the…
-
4
votes1
answer289
viewsChr$ equivalent function in C#
I’m migrating a chunk of code in Visual Basic 6 and came across the following call: variavel = Chr$(27) & Chr(15) 1 - What would be the equivalent functions in C#? 2 - What is the difference…
-
4
votes2
answers129
viewsWhat is the difference between LINQ research forms with Datetime.Now?
I am running two code snippets and they are giving different results. Does anyone know why? This code shows coupons only that have the validity of the current date and time + 3h (I don’t know why):…
-
4
votes2
answers210
viewsImprove function performance that determines whether it is palindromic
Objective: to optimize performance Description of the problem: I have a function that returns me if the word is a palindrome with true otherwise with `false, until then quiet, but need to improve…
-
4
votes1
answer172
views -
4
votes1
answer76
viewsData to string conversion
I’m developing a project and I’m having a problem with a date-to-string conversion (I believe that’s it). I am counting months between a date and another (algorithm obtained in this other question,…
-
4
votes1
answer767
viewsAccess methods from another Form
I have a form called TelaInicio where I have a method CarregarGrid() I would like to access this method through my other form Cadastrar I’ve left the method CarregarGrid()as public but still do not…
-
4
votes2
answers176
viewsDoing a LINQ function that can be called in an EF query
I have the following expression: Where(cd => cd.Modal == modal) .Select(s => s.Volume) .DefaultIfEmpty(0) .Sum() what use to make a same calculation several times within a few querys through…
-
4
votes1
answer98
viewsBug to popular a Data Gridview in Window Forms
To popular my grid the values are not aligned correctly, as the image below. This is my Load Form code: DatabaseRepository db = new DatabaseRepository(); var colunas = db.GetColumnsName(); var…
-
4
votes1
answer199
viewsHow to read an XML that is inside the project?
I’m creating a web application with .NET Core Razor and I need to get my code to read a file XML. I can already get him to read this XML, but with another path, which is out of my project. That is,…
-
4
votes1
answer113
viewsHow should I assign strings in C#?
As far as I know, System.String no. NET (I don’t know if on other platforms the string type is also like this) is immutable, ie if I do: string a = "texto"; a = "outro texto"; Behind the scenes, by…
-
4
votes3
answers214
viewsError: "Return should not be followed by an object expression"
I have this function that has a simple registration but is not registering My doubt would be on that return RES; which gives the error message below the code. //botao para cadastrar OS private void…
-
4
votes1
answer142
viewsProblem with System.Indexoutofrangeexception in C#
I need to create a class Marca and a Modelo, both related to cars, where model will know your brand and brand should know your models. Model Class: namespace AssocMatrizes.Model { class Modelo {…
-
4
votes1
answer54
viewsExpression generation for EF with dynamic properties
I’d like to conduct a search on where for Entity Framework passing the name of the property you would like to compare as a string. For example, I have the following classes: public class ClientData…
-
4
votes1
answer213
viewsStackoverflow error when compiling code in C#
I am doing an exercise in C# and I am not able to find the error in my code, because I have already checked the resolution of the problem and I can’t find the difference in the syntax of the code…
-
4
votes2
answers123
viewsHow far should we follow OCP?
When developing a screen for a certain part of a system, I come across a classic situation of owning some ifs to determine what action should be taken. I then linked this case to examples of OCP…
-
4
votes1
answer115
viewsCreating a dictionary with void functions
I am for fun to develop a TCP server in C# that performs functions depending on the message that the connected client sends you, for now, I only managed to do what I want with functions that return…
-
3
votes2
answers3847
viewsIs it possible to assign the default value of a property with an attribute?
I wish I could declare a property as: [DefaultValue(10)] public int Maximo { get; set; } And when I was going to use it, it already came with the value started in 10. However the attribute does not…
-
3
votes4
answers7116
viewsHow to hide the time of a "Datetime?" field in the user interface?
The time is appearing for the user. My question: it is possible to hide the time and show only the date? How are you showing: Model code: View code:…
-
3
votes3
answers2054
viewsProtect the connection string in a . NET Winforms application?
I have an app .NET Windows Forms connecting to a server SQL Server directly, without the use of an intermediate layer as a Webservice or Webapi, through SqlConnection. This application is installed…