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
-
2
votes1
answer308
viewsGeneric Method for REST Query
I need to refactor this method to make it work better. This method works perfectly when calling on an external API Rest returns list. However, it gives exception when the return object of the…
-
2
votes1
answer55
viewsC# - Use form data in IF
I am trying to recover data from the form and need to use them in an IF. protected void btnSubmit_Click(object sender, EventArgs e) { try { if (txtLocalizacao.Text != "") { conn.Open(); SqlCommand…
-
2
votes1
answer71
viewsAutomatic Cache Time Expiring
I am using the function below to store the cache was working normal, but now when add the time of 60min is as if it expires auto, now if I insert a longer time as 181min the cache is maintained. If…
-
2
votes1
answer47
viewsWindows service, using async method, is there a need?
In my system, I have some auxiliary routines, which are fired at defined times, outside of work hours. These routines are run by a Windows service program. Would you need to run these asynchronous…
-
2
votes2
answers475
viewsUntreated exception (index based on 0)
My idea is to make a small registration and I’m testing this to later add this data in a BD. The problem occurs on the line Console.Write("\nGenero do disco : {1}", genero);, at the time of…
-
2
votes2
answers3157
viewsStart Windows Forms program in the background
I developed a monitoring application using Windows Forms, but it has no need to have anything visual at the moment, so I would like when running it, it to be executed in the background (I would like…
-
2
votes1
answer27
viewsKendo ui Numerictextboxfor - Set startup values
How can I set a default startup value for the field Numerictextboxfor kendo’s. Ex: My field is empty initialized. I want it to come with a default set by me: @(Html.Kendo().NumericTextBoxFor(model…
-
2
votes2
answers3402
viewsError: Not all code paths return a value
Follow the error: "Logincliente(string, string)":not all source paths return a value class Conta { #region atributos public String nomeCliente { get; set; } public String numAgencia { get; set; }…
-
2
votes2
answers1028
viewsHow to query containing MAX and COUNT via LINQ
I got the following model: public class Crm_Analise { [Key] public int id { get; set; } public string cod_item_CRM { get; set; } public string TAG { get; set; } public string data_creat { get; set;…
-
2
votes1
answer108
viewsWork with sound on . NET
In . NET it is relatively easy and simple to work with images. It is possible to use the class System.Drawing.Bitmap to open images in Bitmap, Jpeg and PNG formats and play with your pixels. The…
.netasked 7 years, 3 months ago Oralista de Sistemas 23,115 -
2
votes2
answers2426
viewsDisplaynamefor and Displayfor
Studying about ASP.NET MVC, I came across the following lines of code: @Html.DisplayNameFor(model => model.Title) @Html.DisplayFor(model => model.Title) I can’t understand the difference…
-
2
votes2
answers165
viewsCan’t find Parameter passed to the Insert command
I am developing a web application in ASP.NET and I want to insert data in a table in the database, but when specifying the parameter shows the following error in the…
-
2
votes1
answer171
viewsHow to organize namespaces?
I heard that namespaces should be organized by layer, in case using some Pattern design which makes it possible, as Projeto.Controller, Projeto.UI, Projeto.Model, however, if we look at the…
-
2
votes1
answer734
viewsHow to represent the Real type in C#?
I have an existing table in a bank of a client of mine and there has an attribute with the data type REAL. Like I do at C#? float or decimal? Which is the best way?…
-
2
votes2
answers1884
viewsWhat are model and model variables for in a View?
What are variables for @model and Model in a view? In my view I use it at the beginning of the code: @using Html5DataList.Models @model List<Estabelecimento> And to access the data, I use it…
-
2
votes1
answer111
viewsError when performing LINQ query with equals in Where enclosure
When executing the query below: public ActionResult GridViewPartial() { if (Session["cod_cli"] != null) { int cod_cli = Convert.ToInt32(Session["cod_cli"]); //var model = db.DadosTecnicos; var model…
-
2
votes2
answers232
viewsHow to Suggest Name when Saving Crystal Report
Does anyone know how to suggest name when saving Crystal Report C#, in the dialog box, windows form? The format already managed to restrict...: crystalRVEditoraNomeComeca.AllowedExportFormats =…
-
2
votes1
answer82
viewsIs there equivalent to VB.NET Call in C#?
The question is simple. There is a keyword equivalent to Call of Visual Basic.NET in C#? In Visual Basic, I called a class method without having to declare a member explicitly to it: Call New Form()…
-
2
votes3
answers86
viewsWhy do you print the variable type instead of the result?
See the method below: public void TesteLambda() { List<String> selecoes = new List<string>(); selecoes.Add("USA"); selecoes.Add("Brasil"); selecoes.Add("Itália"); selecoes.Add("França");…
-
2
votes2
answers1331
viewsHow to remove the value of the last Textbox position with Substring?
How to remove the value of the last position of the TextBox with the Substring? Suppose the TextBox receive a value with this mascara = 0,00%, however, I just want to save the numbers and not the…
-
2
votes3
answers40
viewsSystem.Nullreferenceexception in an attribute of type Stringbuilder
Why error occurs? How to fix? Model: public class modelExemplo { public StringBuilder listNewsletter { get; set; } } Controller: public ActionResult funcaodeteste() { modelExemplo obj = new…
-
2
votes1
answer178
viewsGeneric Class Receiving a Generic List>?
In c# I can implement a generic class where 1 of the received attributes is a List<>? object something like: public class Negocio<TEnt, TDto, TDao, TList<coisas>> So you can call…
-
2
votes2
answers73
viewsCreate folder on every console usage
I took a program ready on the internet to create folder, so I tried to adapt it for me but I’m not getting. I’d like every time I executed it, to create a subfolder inside the main under a different…
-
2
votes1
answer122
viewsTreatment of exceptions of different types
try { await DoFooAsync(); } catch (Exception e) { if(e is TaskCancelledException || e is UnauthorizedAccessException) { // ... } throw; } The block catch from the above section checks the type of…
-
2
votes1
answer112
viewsError reading text file line by line
I am trying to read a very large file row by row and add in a list, but when it arrives at a certain point I get an error: System.OutOfMemoryException Is there any way to read this whole file in a…
-
2
votes1
answer44
viewsConsole write 2 strings from the list
I created a list in which I added 2 strings: var lista = new List<string> {cliente.Nome, cliente.Sobrenome}; And in the end I wanted you to show it like this: Console.WriteLine(lista[0]); But…
-
2
votes2
answers59
viewsTaskcompletionsource<Tresult> without a type parameter
The class TaskCompletionSource<TResult> needs a type TResult. That way, when I need to use this class without having a return type (void), I have to do something like: var tcs = new…
-
2
votes2
answers414
viewsVB.NET - Find text in XML file
I need help to validate an XML file I’m using as a database. I insert the data correctly, but I need to do a validation to not insert repeated files, so I need to check if the text already exists…
-
2
votes2
answers78
viewsWhat is the correct way to send a form to a controller via AJAX?
I have a simple form, which is basically my Viewmodel. I am doing a post via AJAX passing this form, however, on the server side, everything is always null. My AJAX is as follows: var formData =…
-
2
votes1
answer544
viewsCheck null or empty fields in an entity without consecutive use of "if-Else"
In a system integration there are data updates on both sides, where you get the record of Side A and the record of side B. If there are null fields in A and these exist in B then A is supplemented…
-
2
votes1
answer680
viewsShow specific error in ASP.NET MVC
I created a site that works normally, however, when uploading it to the hosting server, it shows an error: Server Error in Application '/'. Since the error is too generic, he says to include the…
-
2
votes1
answer52
viewsHow is the encryption of a Securestring made and stored?
The class SecureString is used to represent a text that must be kept confidential in memory (passwords, card numbers, balances, etc.), and carries out its correct deletion from memory when said text…
-
2
votes1
answer271
viewsUsing TLS 1.2 in . NET Framework 2.0
I’m looking to use TLS 1.2 on a call Webclient in the framework .NET 2.0 It is possible? try { using (System.Net.WebClient client = new System.Net.WebClient()) { string u = client.UploadString(url,…
-
2
votes1
answer211
viewsHow many threads should I split a task into?
I am developing an application in C#, one of my functions can be run with multiple threads. However, how many should I use? If the processor has 4 cores, there is advantage in using more than 4…
-
2
votes1
answer1538
viewsThe . NET Framework 4.7.1 or a later update has already been installed on the computer
While trying to install the newer version of . net, an error appeared informing: Installation will not occur. See the reasons below. Details The . NET Framework 4.7.1 or a later update has already…
-
2
votes1
answer106
viewsWhat is the purpose of the "[Bind("ID,Title,Releasedate,Genre,Price")]" feature in a method?
I am creating a project in ASP.NET Core MVC for learning purposes. In a certain part of the Microsoft guide when the technique of scaffold to generate the controller and the views corresponding to…
-
2
votes1
answer891
viewsCan I edit Identity’s Aspnetusers table?
Galera I have a project that has a table of USUARIOS. And now we’re migrating to AspNet.Identity which already has a table but called AspNetUser and with your own fields. And my table USUARIOS have…
-
2
votes0
answers48
viewsXamarin Forms. Collect camera frames
Greetings to all! There arose the need to develop an application where my greatest difficulty right now is to load the camera from the mobile phone on an object and somehow get some event…
-
2
votes1
answer169
viewsWhat are the "User" and "Cancellationtoken" parameters for?
I’m doing an implementation with the API from Google Drive, and in the code block: credenciais = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, new[] {…
-
2
votes1
answer111
viewsHow to print the name of the method, file and line that was called?
Example: file name: teste.cs A part of the code: ... public void MeuMetodo() { // suponha que essa linha seja a 100 Console.WriteLine("Arquivo: " + arquivo + "Metodo: " + metodo +" linha: " +…
-
2
votes1
answer136
viewsIs it possible to omit the numbers of the "String.Format" formatting arguments in C#?
I was seeing that in Python is possible format a string without numbering the arguments. Example: #mensagem = "Meu nome é {0} e minha idade é {1}"; mensagem = "Meu nome é {} e minha idade é…
-
2
votes1
answer56
viewsCan MSIL be converted to Native code?
I can convert a . NET Framework generated from a C# executable to a code Native code? If yes, from this Native code, I can transcode to other languages like C++? If not, there is a lower level of…
.netasked 6 years, 9 months ago CypherPotato 9,292 -
2
votes1
answer124
viewsDictionary<string, string> or Namevaluecollection?
What’s the difference in using Dictionary<string, string> and NameValueCollection? I researched, but only found in English in the same Sopt, I used the translator, but the translation became…
-
2
votes1
answer81
viewsPerform tracking and debugging on . NET
During the development of an application, there are times when I get lost and want to understand how my code is running. For example, in which iteration of a particular loop of repetition it is,…
-
2
votes1
answer194
viewsStore all types of variables in an array/array?
How can I store values and variables of all types within a vector? Ex: vetor1.Add("valor em string"); vetor1.Add(100); vetor1.Add(100.10); vetor1.Add(-100); I have no idea how I can do this.…
-
2
votes2
answers290
views -
2
votes1
answer1186
viewsMultiple select list with items already selected using Razor
I’m using Razor to generate a SelectList thus: @Html.DropDownList("StatusImovel", new SelectList(ViewBag.ListaStatus, "IdStatus", "Descricao"), new { @hidden = "hidden", @multiple = "multiple",…
-
2
votes0
answers1319
views -
2
votes2
answers67
viewsWhat is the best performance in comparison of string sizes?
What is the best performance option? And memory allocation? Using option 1 or 2? String text = "ola mundo"; Option 1: If ( Strings.len(text) > 0 ) {} Option 2: If ( text != "") {}…
-
2
votes1
answer104
viewsWhy does adding a variable, property, method, etc. to a string work?
When I add a variable, property, method, enumerator, etc. into a string, it works, even though I’m not calling the method ToString() for example. Example with type and integer: var example =…