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
-
3
votes1
answer180
viewsVariable with unassigned value within a "for" loop
int i; string cpf; cpf = "11111111111"; DbConnection cnx = ADO_Utils.GetConnection(); DbCommand cmd = ADO_Utils.GetComando(cnx); cmd.CommandType = CommandType.Text; for (i = 1; i <…
-
3
votes1
answer96
viewsLINQ to SQL Inheritancemappingattribute Code property
What is the purpose of the property Code of the attribute InheritanceMappingAttribute? The documentation describes this way: This Property Holds a value that appears in the database table in the…
-
3
votes2
answers837
viewsOperator error cannot be applied to the method group
I’m trying to print a date subtraction using C# with Webforms, but I don’t know how to correctly insert attributes in methods or how to print the method. I’m converting the subtraction of dates into…
-
3
votes1
answer36
viewsUpdatepanel - Always and conditional together
I have a question. Is it possible to fire event only on updatePanel conditional while it is inside another that is not conditional? Follow the example: <asp:UpdatePanel runat="server"…
-
3
votes1
answer89
viewsMight there be some error in the execution of foreach in this method?
The execution of the code below may occur some error? protected void ImprimeValores(Ilist<int> values) { if (values.Count > 0 && values != null) { foreach(int v in values)…
-
3
votes4
answers343
viewsWhy not always use Optimize Code?
In Visual Studio there is the option Optimize Code which has the function of creating optimizations performed by the compiler to make your output file smaller, faster and more efficient. Why can’t I…
-
3
votes1
answer159
viewsRun an Attribute constructor
How do I call the constructor of an attribute before the constructor of the decorated class? For example, I have my attribute: using System; namespace T.WinForm { public class TesteAttribute :…
-
3
votes1
answer174
viewsSource is not recognized in PDF generation
I am using the Itextsharp library to create PDF’s and I am having problems with the source of the document, I have the error "Font is an ambiguous", I have looked in several places and all the…
-
3
votes1
answer1299
viewsHow to include a column that dynamically demonstrates image in a Gridview
I am generating a report and exporting to Excel, but as most reports the number of columns is dynamic and I am mounting the gridview dynamically. I need to demonstrate a column that displays images…
-
3
votes0
answers33
viewsNamespace function beyond C#grouping
Hello I was here thinking a little bit and I came up with a little doubt regarding the use of namespace in C#, it would have some function other than the grouping of "similar objects" ? And in a…
-
3
votes1
answer288
viewsHow to make a foreach loop with limit in c#?
How can I make a limit foreach loop, for example I have a dictionary with 100 items and I want to make a loop of item 20 until 50 as I can do this in c#.
-
3
votes2
answers247
viewsI need to get a description of the task manager process
I need to get the name of the process that is active on the screen, but I need to bring equal appears in Task Manager description. For example if I use processName it will bring "Chrome" I need it…
-
3
votes2
answers223
viewsWhich database is ideal for my scenario?
I am developing a commercial automation system (C# and Windows Forms) that can be installed on one or several machines on the same local network. I did the part mobile system, where it is possible…
-
3
votes3
answers271
viewsChange read-only property in class itself
A read-only property implements only the provider get. But what if I want to modify this property in the class itself? Let’s say public class MinhaClasse { public string PropriedadeDeMinhaClasse {…
-
3
votes2
answers407
viewsCompletion of mandatory fields
How do I force at least one of the two fields to be mandatory (is filled)? For example, the fields Celular and Telefone cannot be saved empty, only one of them. My code: //.. } else ((txtNome.Text…
-
3
votes1
answer115
viewsProblem with calculation result greater than Int64
I am doing the exponent of a number and I need the result to come out in a specific format, however I do not know how to do, follow the code: double num1 = 290287121823; double num2 = 538783; double…
-
3
votes1
answer142
viewsNullreferenceexception when calling function
I’m creating some unit tests for a class library that does manipulations in a database. The method being tested is this: public object ExecuteNoQueryOperation ( string spOrSqlInstructions,…
-
3
votes1
answer63
viewsNullreferenceexception using Htmlagilitypack
I wonder how many tags <a> exist within a div, but the Exception NullReferenceException is fired when arriving on Xpath. var baseURL = "AQUI VAI A MINHA URL"; var client = new HtmlWeb(); var…
c# .net exception html-agility-pack nullpointerexceptionasked 8 years, 3 months ago Gabriel Bernardone 563 -
3
votes3
answers134
viewsUnderstand "," as "." when formatting
My Visual Studio is getting a little wrong what I type (console): using System; namespace Uri_CSharp { class URI { static void Main(string[] args) { double raio = double.Parse(Console.ReadLine()),…
-
3
votes2
answers407
viewsSaving file path in Mysql
I’m having trouble saving file address in the database. When saving the address in the bank it is adding the amount of times I used the OpenFileDialog to save a file. Always save the address like…
-
3
votes3
answers823
viewsMethod that returns parent class to daughter class
I have the following classes: public class Pessoa { public int PessoaId { get; set; } public string Nome { get; set; } public DateTime DataNascimento { get; set; } } public class Cliente : Pessoa {…
-
3
votes1
answer1627
viewsUsercontrol, what is it? When to use?
I am studying the best way to do a user control in a WPF application, but I have some questions regarding the UserControl available in VS 2015. I have already programmed an access control, ie user…
-
3
votes1
answer1975
viewsCalculate square root in C#
I have a calculator made in WPF C# with basic operations +,-,*,/, % . And now I wanted to try to improve my calculator. namespace calculadora { public delegate float? dlgoperacao(float? a, float?…
-
3
votes1
answer67
viewsInlinestring vs String - what’s the difference?
In the creation of some spreadsheets with Openxml, I came to doubt the difference between: CellValues.InlineString CellValues.String There is some practical difference when inserting texts (e.g.:…
-
3
votes2
answers843
viewsOverwrite methods based on name only
I’m creating an abstract base class to provide a pattern for other classes. The base class methods shall be superscripted in the derived class. Now comes the cat jump. The superscript should happen…
-
3
votes3
answers149
viewsHow to generate new code from DBO
I have a table with the name Produtos in which I inserted 3 products for testing. Now I’m assembling the product registration form and I need to always generate a sequential product code from the…
-
3
votes1
answer76
viewsWhat do the following column/row measurements mean?
In creating rows or columns of WPF, which means each of these measures? <Grid.ColumnDefinitions> <ColumnDefinition Width="50"/> <ColumnDefinition Width="50*"/> <ColumnDefinition…
-
3
votes2
answers153
viewsKeyword for C# equivalent to Java’s "Synchronized"
Problem I am implementing a connection manager that implements the standard Singleton, managing a pool connections with unique keys for each new connection. So I’m having problems with the…
-
3
votes3
answers682
viewsWhat is the difference between Smtpclient.Sendasync and Smtpclient.Send() using Thread?
What difference between using SmtpClient.SendAsync() and create threads and execute the SmtpClient.Send() for messaging? There is a lot of difference in performance or resource consumption?…
-
3
votes2
answers131
viewsAPI does not receive list post
I have an API that receives a post, if I receive only a single contract, it receives the data normally: [HttpPost("GravaContratos")] public async Task<JsonResult> GravaContratos(ContratoModel…
-
3
votes2
answers2511
viewsHow to add item in array through a foreach?
I’m doing a check in a directory where I list all items with a specific extension. And I need to add the items into one array through a foreach. Follow part of the code I’ve tried. DirectoryInfo di…
-
3
votes1
answer3125
viewsWhy does calling a simple method in a class give a reference error?
I’m starting to study C# and I’m making the following mistake: CODE: CS0120 DESCRIPTION: An Object Reference is required for the non-static field, method, or Property…
-
3
votes1
answer115
viewsHow do I know the client sent me something?
I made this code here following some tutorials over the internet. buttonAbrirConexão.Enabled = false; TcpListener servidor = new TcpListener(6554); servidor.Start(); while(true) {…
-
3
votes3
answers468
viewsSearch for word in the first array column
How do I search for a word in all lines, but only in the first column of a array that will always increase in size? string[,] array = new string[1,6]{{"texto","","","","",""}};…
-
3
votes0
answers901
viewsCompiler crash with error code 255. bin Roslyn csc.exe
Build Error Description: Error when compiling a resource needed to meet this request. Examine the specific details of the error and modify the source code appropriately. Compiler Error Message:…
-
3
votes1
answer142
viewsHow to place a Readonly column?
I’m trying to leave only one column of GridView as ReadOnly, I’m doing like this: if (id_crm == 0) { textBox2.Text = Convert.ToString(cod_crm()); DataTable dat_itens = new DataTable();…
-
3
votes1
answer2475
viewsIs there a reliable way to test the internet connection?
I read about the function NetworkInterface.GetIsNetworkAvailable, but it does not work in my case, since I need to check if there is really an internet connection. I also read about trying to access…
-
3
votes1
answer101
viewsSend email without it appearing in the mailbox
I don’t want those items sent in the real estate email. string emailOrigem = imobiliaria.Email; string password = imobiliaria.Senha; string html = getBody(dados); //aqui serve pra formata o html if…
-
3
votes1
answer76
viewsFunction that returns other functions
I have three methods being called separately on controller with JSON. Each one of them returns to me Id Name. I need to call these three methods in the same function in the controller. How can I…
-
3
votes1
answer2266
views -
3
votes2
answers1159
viewsConvert string to integer
I can’t convert my text TextBox in one piece. namespace Pag98_Exe1 { public partial class frmveiculos : Form { public frmveiculos() { InitializeComponent(); } Veiculos veiculos = new Veiculos();…
-
3
votes1
answer75
viewsClaims no Testmethod
Good morning, you guys, I’m starting TDD in Visual Studio, and I’m having problems/difficulties passing Claims permissions on the request that is made to the server. The following error is…
-
3
votes1
answer151
viewsMVC Helper with List Energy
I am creating a Helper in my Asp.Net MVC 5 project, and would like to receive as a parameter a generic list, but the following code snippet does not work: @helper MeuHelper(string param1, int…
-
3
votes2
answers1191
viewsDoing operations/handling Datetime
The idea is for the user to type in a textbox to horaEntrada and in another to horaSaida where in the case of these two variables they should have the format "HH:mm" hours and minutes only…
-
3
votes1
answer116
viewsThe Entity type 'Personal' is part of a Hierarchy, but does not have a discriminator value configured
I am trying to generate Migrations using the command: dotnet ef migrations add InitialMigration --context MyContext and the same is returning me the following message.…
-
3
votes1
answer275
viewsHow to serialize a datetime displaying in the dd-MM-yyyy hh:mm:ss format
How do I send to View() of my Controller in Json format, the default formatted date dd-MM-yyyy hh:mm:ss? In the transport of data between View and Controller I am using AJAX. public ActionResult…
-
3
votes1
answer466
viewsReload Datagridview in C#
I am creating an event of a button in which it creates a Product object and adds in a list of Products and using this list to fill the Datasource of a dataGridView, but Datagridview keeps appearing…
-
3
votes1
answer459
viewsExecute 2 querys or more
I wanted to execute 2 darlings in C# when the button is clicked, but I can only execute one. public static void excluireventos() { string connectionString = Conn.tank(); using (SqlConnection…
-
3
votes2
answers411
viewsTextbox_changed is accumulating the sum value c#
I’m using the event textBox_Changed and when I type a value into the field, another textBox should receive this value, but this other textBox called ValorTotalVenda is accumulating this amount.…
-
3
votes2
answers510
viewsCreate class instance in threads
Imagine I have a class: Class Animal { //Propriedades } Now creating multiple instances of the class I do as follows: Animal[] animais = new Animal[10]; for(int i = 0; i < 10; i++) { animais[i] =…