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
-
1
votes2
answers726
viewsHow to read numbers from a txt file in C#?
This is an example file: 2 0.03159527 0.1990048 0.9794891 0.02173799 0.9969404 0.07508247 The first number indicates how many lines are, for each line are always three numbers I tried to do…
-
1
votes2
answers1520
viewsParameter in bold C#
I have the following string: string frase = string.Format("A data de hoje é: {0}", DateTime.Now.Date); Is there any way to make the parameter bold?
-
1
votes2
answers317
viewsRandom list in Query Linq to Entity C#
I would like to get a list of 3 objects within a query Link. var listaPessoas = from i in this.Context.CreateObjectSet<listaPessoas>() select i; ... listaPessoas = listaPessoas .Where(x =>…
-
1
votes2
answers135
viewsWhy only an Encoding works in the algorithm?
Here’s the deal: I have an encryption module that encrypts a byte[] and out another byte[] encrypted, and at the end of the output a checksum is placed; the checksum is a single byte generated by…
-
1
votes1
answer77
viewsHow to put a form inside a tab?
I want to add a form inside a tab, I have tried using the command "this.tabPage1.Controls.Add(new Form1);" and it did not work, how to proceed?
-
1
votes2
answers86
viewsIs there a sure way not to wait for a lawsuit?
There is a safe way not to wait for a process on . NET? async Task DoFoo() { // ... GravarLog(); // ... } void GravarLog() { // ... } In the above code, my entire process will wait for the method to…
-
1
votes1
answer71
viewsI’m not able to add a reference to my program
I need to use this structure. The problem is that I’m unable to find it in the . NET Framework. I’ve already added a reference to System.Numerics and put the using, but I still can’t use it. I also…
-
1
votes1
answer274
viewsStandardize error messages in Dataannotations in Viewmodels classes
It is possible to standardize the error messages used in Dataannotations, so that it is not necessary to pass a string like: [Required(ErrorMessage = "Este campo é obrigatório.")] But you can use it…
-
1
votes0
answers267
viewsHow to change the default folder of an ASP . NET Core application?
I am trying to set up an ASP site . NET Core, to host an Angularjs application. The structure my "index" page is using is: /wwwroot/app/index.html I tried some settings in the Startup.Cs file, like…
-
1
votes1
answer69
viewsC# - Outofmemoryexception when searching for thousands of Active Directory groups
I’m searching thousands of groups with hundreds of users each of Active Directory, but it’s consuming a lot of memory. It starts with about 300 MB and when it reaches about 1800 MB, seen in the task…
-
1
votes2
answers324
viewsFirstordefault, Singleordefault, Elementatordefault
What is the difference between the elements FirstOrDefault and First, SingleOrDefault and Single or ElementAtOrDefault or ElementAt. When to use with and without the Default?…
-
1
votes2
answers80
viewsMethod is executed by clicking the button despite doing "button01.Enabled = false"
I want to disable a button while the method does not finish. I used button01.Enabled = false;, but even clicking while the button is disabled, the method is called again after it ends. For example,…
-
1
votes1
answer36
views -
1
votes1
answer129
viewsHow to handle a rendering Exception in WPF (Windows Presentation Framework)
Randomly my system causes this Exception (which I only see because of the logs left in Windows events). It’s an app that runs around 24 hours a day every day. When error occurs, the screen freezes…
-
1
votes1
answer378
viewsForce user to select Radio Button inside the Groupbox
How do I force user to select a Radio Button inside the Groupbox. Example of the image below…
-
1
votes1
answer136
viewsFile closure
I need to leave the file free, without getting in use, because it is blocking. Follow the code: StringWriter sw = new StringWriter(); XmlTextWriter tw = new XmlTextWriter(sw);…
-
1
votes1
answer93
viewsTransactionscope with multiple Storedprocedures
I’m thinking of implementing TransactionScope in my code, however, all bank access is made by StoredProcedures. The TransactionScope can give rollback in multiple actions carried out in…
-
1
votes0
answers250
viewsDifference in using clause using within namespace
There is some difference in performance / execution / compilation of C# code when using clauses using inside the namespace? Basically what I want to know is if there is a difference (beyond…
-
1
votes0
answers84
viewsdmColor and dmDuplex values of the DEVMODE structure always returning 0
I am doing a C# printing monitoring job and using the winspool API. I was able to capture much of the data I need, such as number of pages, printed document, number of printed pages, user who…
-
1
votes2
answers84
viewsError while trying to deserialize JSON from a web page
I’m using Luis.ai to create my neural network of intents and Microsoft Bot Framework to create my chatbot, but I’m not able to read a json that luis is generating for me. Luis' class: public static…
-
1
votes1
answer410
viewsDisplay saved image in database and allow user to change image
I am retrieving the database information and checking whether the GIF and Image fields are null or not to display to the user the best option in View Edit. Anyway, follow the code where I do this…
-
1
votes2
answers395
viewsTreating JSON in C#
I have a return of an HTTP request in JSON format. It comes as follows: { "message": "authenticate" } It’s a simple return, but I’m a beginner in C# and would like to know how to assign only the…
-
1
votes2
answers245
viewsString Manipulation in VB.Net
Hello, in the code I’m developing I need to get the name of a file. I used an Openfiledialog for the user to select a file and, after selecting, the system returns the directory of this file within…
-
1
votes0
answers31
viewsRequest status after browser close
I have an Asp.Net MVC project and I realized that when I close the browser immediately after the beginning of a request (without waiting for its due ending), it makes somehow the server does not…
-
1
votes2
answers200
viewsHow to convert text into file to number with decimals?
I have this data written in the text file "000001010" (you only have this data), but I wanted when it was for the variable to be like this 10.10. I’m reading the file data like this: var linhas =…
-
1
votes0
answers60
viewsMultiple calls to the webservice
I would like to know the best way to make N calls to the same Webservice. Ex.: In a search system / hotel quotation, as a strategy, we use N calls for a specific quote because in each call is sent a…
-
1
votes0
answers293
viewsBest practices for using Try / Catch blocs
What is the best strategy to use Try / Catch blocks: try { //FAÇA ALGO } catch(Exception ex){ //LOGAR O ERRO //LANÇAR O ERRO PARA CIMA? } Example: A tax calculation operation starts the process by…
-
1
votes2
answers754
viewsLoop for ATM
I need to run this code until user asks to quit. In case, it will inform the result at the end and follow up with a question to the user if he wants to continue using, then the code runs again until…
-
1
votes2
answers398
viewsWhat is the best way to authenticate in the database?
What is the best way to connect to the database using c#? Create a USUARIOS table, or create a USER in the database to access?
-
1
votes1
answer992
viewsCheck if there is value in the enumeration by the attribute and return its value
It is possible to produce simpler code for this function without changing the enum? /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]…
-
1
votes1
answer51
viewsHow I get the object or value of a tr with Datatable
function excluirDadosTabela (){ $('#gridtabelaDocumentos').on('click', '.excluir', function(e){ e.preventDefault(); var teste =…
-
1
votes1
answer112
viewsHow to update javascript file content on the page?
I searched in the forum and did not find a definitive solution, my problem is with regard to browser cache, when I make a change in a javascript file, my client only gets the updated file after…
-
1
votes1
answer2196
viewsHow to call a "Stored Procedure" oracle c#
I have the following Procedure in my bank: I’m trying to call my store Procedure in the .net in this way: public int CountEvent(int resourceId, int eventCounterDefinitionId, DateTime startDate,…
-
1
votes1
answer82
viewsHow to treat an index band exception?
I’m having an exception problem on my show and I’m not sure how to treat it. Follow the error image in Datagridview. private void DGW_solictacao_CellClick(object sender, DataGridViewCellEventArgs e)…
-
1
votes2
answers84
viewsComparing two objects and copying conditionally
I have the following classes: public class Pessoal { public int ID { get; set; } public string CPF { get; set; } public string PIS { get; set; } public string NOME { get; set; } ... ... ... } public…
-
1
votes2
answers96
views -
1
votes0
answers147
viewsHow to compile C# code at runtime in an ASP.NET MVC5 project?
I tried to use the CodeDom, but when trying to find a DLL specific to execute my code the command Assembly.GetEntryAssembly().Location always returns to me null. It seems the projects ASP.NET are…
-
1
votes2
answers138
viewsTolist() returning read-only
Follows code: using (var db = new Entities()) { var result = db .Tabela1 .Select(x => new { x.Coluna1, x.Coluna2 }) .ToList(); foreach (var item in result) { if (item.Coluna1 == string.Empty) {…
-
1
votes1
answer150
viewsGoogle Analytics use API . NET for pageviews information
How do I search for Pageview information from a particular URL of my website via programming using some Google Analitcs API. Note that I already have the whole site configured in Google Analytics.…
-
1
votes1
answer304
viewsUse Text User Interfaces in C#?
I would like to give a basic interface to an application developed in Console Application. I want to make use of features like TUI (Text-Based User Interfaces), common on other platforms like…
-
1
votes1
answer57
viewsView window without frameworks
How can I display a window without using frameworks? For example, display the console window or another without the . NET and others frameworks.
-
1
votes1
answer32
viewsGoogleapi in Visualstudio
I’m trying to implement on top of a ready-made class that I was sent that uses Googleapi, but I can’t possibly add the reference to the project via Nuget. Do you know where I can download it? Follow…
-
1
votes3
answers1181
viewsHow to access the elements of a list declared in a different class?
I have developed a code that generates a list when the following input data is informed: List size (or how many "Indexes") The values that will fill the said "Indexes". Values are collected within a…
-
1
votes1
answer139
viewsGrab all images from a subdirectory except for a folder
I’m picking up all the photos from a directory and its subsequent ones, but I wouldn’t want it to be the "Backup" folder, as I could do that? string[] Arquivos = Directory.GetFiles(PathEx, "*.*",…
-
1
votes1
answer1680
viewsReplace com does not work
I’m trying to make a Replace() but it doesn’t work. I need to change \ for \\. "\r\n".Replace(@"\", "\\"); he just returns me : "\r\n" and not "\\r\\n".…
-
1
votes1
answer191
viewsRun method of one nested class as property in another in C#
I have the following class: public class Feliz : IFeliz { //public algumas propeiedades e tals... { get; set; } public bool EstaFeliz() { //Faz alguma coisa... } } And she’s a property in another…
-
1
votes2
answers1505
viewsSearch file path C#?
I need to find a file path .wav in C#. I can find and execute the .wav with the complete path "c: caminhox...", however, I need the application to find the file in any directory that he is. I tried…
-
1
votes3
answers178
viewsHow to store a single character?
My class has an attribute that is a single character. I can store as string, but I think the right thing would be char. Only this attribute can receive one int (between 0 and 9) another method. How…
-
1
votes1
answer275
viewsPass complex object vs simplest object per parameter
In the method Log there is the type parameter HttpClient. The function only uses the parameter to access the property BaseAddress, which is a Uri. private void Log(string verb, HttpClient…
-
1
votes2
answers81
viewsHow to restrict a set of a property?
I have the following property in my class: public char Naipe { get; set; } This property can only receive one of the following values: (char)9824 (Espada) (char)9827 (Paus) (char)9829 (Copas)…