Most voted "c#" questions
This tag should be used when the question refers to some resource, information or problem related to the C#language. C# ("C Sharp") is a multi-paradigm programming language that has strongly typed variables, is imperative, declarative, functional, generic, object-oriented and component-oriented, which are designed to be executed in . NET Framework.
Learn more…13,899 questions
Sort by count of
-
3
votes3
answers345
viewsDynamic search in c# and WPF
Good morning I would like to ask a question about a dynamic research. Setting: I have a search screen, where the user selects 3 fields, being them: The first is the search screen field, where you…
-
3
votes1
answer89
viewsConvert all strings to lowercase
There is a way to configure the modelBuider, to lower my strings? For example, when I want all my data of type string, be at my bank a varchar, i make the following configuration:…
-
3
votes2
answers985
viewsProblem while recovering null data to a Datatable in C#
I am working with C# and the Postgresql Database, I have a field of type Date where it can be filled dd/mm/yyyy or null empty. the same problem refers to any field of the table, if it is empty, even…
-
3
votes1
answer203
views -
3
votes2
answers498
viewsAuto Refresh in Xamarin application.
I am developing an application that in the main screen will have some buttons, and these buttons access a URL sending commands on and off all this through Httpclient and persisting all this…
-
3
votes1
answer269
viewsWhat kind of . NET library should I choose in C#project?
I’m thinking of creating a new project in c# I saw three types of libraries that caught my attention and I couldn’t distinguish exactly what would be the best applicability in each project. .NET…
-
3
votes0
answers41
viewsHow to create an expression evaluator?
I am creating a program that will allow the user to create and execute their own expressions. Looking into it, I found the Compute of DataTable. Ex: DataTable dt = new DataTable(); var exp =…
-
3
votes0
answers62
viewsuse Sqldependency with [ORM]
I am developing a service that must perform a procedure whenever a record as a certain condition is entered in the database. However, despite using the SqlDependency, I’m not using the SqlCommand,…
-
3
votes1
answer722
viewsHow to add a link column in Gridview?
I have the following code that generates my Gridview: protected void Page_Load(object sender, EventArgs e) { try { AlteracoesContrato alteracoes = new AlteracoesContrato(movimentacaoId);…
-
3
votes3
answers603
viewsProblem sending model to controller
I’m having trouble forwarding my model to control: Class: public class Pessoa { public virtual long Id {get; set;} public virtual string Nome {get; set;} public virtual ETipo Tipo {get; set;} public…
-
3
votes1
answer40
views -
3
votes3
answers1393
viewsWhat do I need to know to work with C#backend?
What are the main technologies, tools, finally, what is needed to work with backend using C#?
-
3
votes1
answer54
viewsDoubt with XML file creation
I have a program that creates an XML file using Xmltextwriter, follow the example public static void testeGerarXml() { using (var xml = new XmlTextWriter(@"c:\Gustavo\teste.xml", Encoding.UTF8)) {…
-
3
votes2
answers106
viewsHow to dynamically generate OR comparisons with LINQ?
I have a query where I should find certain values comparing whether a column is equal to a value X. X is an array that can have 1 to 4 values. How can I in mine query with LINQ dynamically assemble…
-
3
votes2
answers154
views -
3
votes1
answer241
viewsC# class as parameter in SQL Server
You can create a class in C# and the same class in SQL Server that represents a tabela (ID, Nome, Telefone) and create a precedent where I would pass as parameter this class . This is the class…
-
3
votes1
answer108
viewsError when calculating decimal value
I need to calculate the interest value, this is the code: public async Task<decimal> CalculatesInterestAsync(decimal valorInicial, int meses, decimal juros) { var valorFinal =…
-
3
votes1
answer675
viewsGeneric Query with Predicatebuilder and Linqkit
I’ve been using Linqkit to create generic queries for a long time. One thing that always bothered me is that I always have to test if the value sent in the filter is valid. For example: Suppose I…
-
3
votes1
answer74
viewsWhy char. Parse(string) returns a number?
I am making a program that uses Typecast, but when I converted a string to char (char.Parse()), received the following return: 115's' What is the reason for the conversion of string to char return a…
-
3
votes1
answer1507
viewsHow to Place Text from a Textbox on a Label? C# WPF
I am developing an application in C# WPF, and I have two Forms. A Form has several Abels (with the name of several fields, such as gender age, name, etc...) and under each of the Abels has a Textbox…
-
3
votes2
answers271
viewsProblem running tasks with two buttons in the same form in c#
I’m new to c, so forgive me for making a rookie mistake. I need to put two buttons on the same form,one to call a form, and another to perform a function I’m trying like this: private void…
-
3
votes2
answers446
viewsRestrict access to only one page in the application, leaving the rest free
I would like to restrict access by requesting login to only one page in my application. In webconfig I put so, but obviously this way requires authentication on all pages of the application.…
-
3
votes2
answers269
viewsSelect in windows form c#
Imagining I have 3 checkbox: 2.9.1 2.9.2 2.9.3 I wanted, that I click on the 2.9.3, selects me all that are behind. It’s the kind of a select all, but only select me from a given number upwards that…
-
3
votes3
answers847
viewsHow to create Login and User in SQL Server passing command line through Visual Studio passing parameters?
public void CriaUsuarioSystem(string userSystem, string pwSystem) { try { conexao = new SqlConnection(conexao_BD); SqlCommand creatUserSystem = new SqlCommand("CREATE LOGIN @login WITH PASSWORD =…
-
3
votes3
answers952
viewsSave date in Brazilian format in Postgresql
I have a Postgresql database on the Windows Azure server that is set to the Brazilian standard. If I do an SQL and run directly in Pgadminiii there from the server and run, the date is saved in…
-
3
votes3
answers1453
viewsCalling form after loading screen
I have already checked some answers that have been made about closing a form after logging in and so on. I have tested the too many methods in my role, but I was unsuccessful. So my problem does not…
-
3
votes2
answers3386
viewsHow to call a nonstatic method within a static class?
I have the following method/function and need to call the method/function criaTimerTendencia that is within the class TagAnalogicaAtiva. private static void VerificaEnvioDeMensagensSignalR(object…
-
3
votes0
answers29
viewsHow to use the onclick attribute in C# Webbrowser?
HtmlElementCollection elementButton = webBrowser1.Document.GetElementsByTagName("a"); foreach (HtmlElement elementyButton in elementButton) { if (elementyButton.GetAttribute("onclick") ==…
-
3
votes1
answer35
viewsBatch persisting in Many-to-Many Entity with extra fields
I have the following question: If I have an N to N relationship: Products and Coins. At the time it would persist would be 1 Product with a list of 10 Coins. public class Produto { public int…
-
3
votes1
answer272
viewsDynamic attributes of an Entity Model
I have a Procedure which returns a number of columns dynamic, because this precedent uses the function Pivot, then the question arises: How to create a Entity Model for this project ?. Example:…
-
3
votes1
answer599
viewsFullcalendar displayed in wrong time
I’m implementing the FullCalendar in a project, I inserted some Events in the database and return them via Json. But when displaying them on the screen, they come with the correct time date, but the…
-
3
votes1
answer59
viewsConvert a Double with more than 13 decimal places to String without losing values
I have in C# the following number in Double: 124.00767638369544. When I simply put valor.toString(), the value goes to: 124.007676383695, IGNORING the 0,00000000000044. The system I’m making needs…
-
3
votes1
answer691
viewsASP.NET Webforms, MVC or Webapi?
First I would like to point out that my knowledge in web development is very small, so my question will be directed on what to use and not how to use, because the goal is to study first and then…
-
3
votes1
answer156
viewsGoogle Drive . NET Quickstart Error to get Credentials
I’m starting to study the Google Drive Api for a personal . NET project, and followed the step by step made available on the google website…
-
3
votes1
answer40
viewsStringbuilder append() converts to string automatically
Why when I use .AppendLine() it is necessary to convert the parameter to string, but when use .Append() conversion is not necessary?
-
3
votes1
answer7066
viewsObject reference is required for non-static "notificationhub" field, method or property
Follows code: void OnChange(object sender, SqlNotificationEventArgs e) { //from here we will send notification message to client NotificationHub.SendNotification("João"); // <----- Aqui .... }…
c#asked 7 years, 4 months ago Matheus Miranda 5,375 -
3
votes1
answer5608
viewsIs there already an open Datareader associated with this command that should be closed first?
I have a combobox that is receiving data from a table of my BD Mysql. So far so good. However, when I return to the home screen, where it is, it ends up giving a problem (There is already a…
-
3
votes0
answers692
viewsHow to validate an XML by Schema XSD?
I’m trying to validate the values of a XML through a file XSD. I’m trying it this way: XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlReader); ValidationEventHandler eventHandler = new…
-
3
votes2
answers1238
viewsCreate key in windows registry without permission in c#
My application needs to insert itself into the Windows Defender exclusions. Simply create a Myapp.exe key on the way {HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exclusions\Processes},…
-
3
votes1
answer100
viewsWhy is the Zipfile function not working?
I found a function on MSDN that I’m needing to use for a program that I’m doing. My problem is that when I try to use it, it appears as if it didn’t exist in C#, remembering that I have already…
-
3
votes1
answer84
viewsNavigation Properties - Domain-Driven Design
Hello, I am studying DDD and came across the following question: There is the Aggregate (Aggregate), a set of related objects that have an Aggregation Root (Aggregate Root). So far so good, I…
-
3
votes1
answer1260
viewsc# read a remote source XML file
I have an API that generates me an XML but whenever I try to get the XML to handle the other side it returns me an error. the XML is this: <ArrayOfResponsaveis…
-
3
votes2
answers2790
viewsHow do I use C# in Javascript? (Visual Studio 2017)
I use little to organize my C code#: #region Nome //seu código #endregion How can I do this by javascript and Razor ? @if() { //code javascript } Update: I checked my answer Gypsy Morrison Mendez…
-
3
votes1
answer143
viewsDoubt with SQL Injection
I have an internal method that is called on the basis of another query, it is this way down. I wonder if this would be a "string.Format" error, if it would be possible to send an Injection SQL?…
-
3
votes2
answers114
viewsMethods with more than one Generic
It is possible to create a method using more than one type of Generic, sort of like this. public static TResult ToEntityForType<TResult>(this DataRow row, TType type) where TType : Type {…
-
3
votes1
answer3224
viewsInput string was not in a correct format
When calling the method below comes the message the input character string was not in a correct format private void SubmitData() { try { string user = usuario.Text; string pass = senha.Text;…
-
3
votes0
answers57
viewsError when using dictionary in a Iqueryable.Select() method to project columns chosen at runtime
The code fragment below aims to use the Select() method to perform generic column projections in a query, according to a list of column names provided. The program works fine if all columns are…
-
3
votes2
answers91
viewsHow to make the code not catch the ASCII Code from a variable?
I’m having a problem trying to add numbers that are in a variable, because it’s taking the ASCII Code from the same. How do I directly pick the number that is within a variable? string bin =…
-
3
votes2
answers904
viewsHow to access properties of an object that is inside another object?
Deep down I want this output Console.WriteLine(cidade1.casas.dono); returns João using System; namespace arrayteste { public class cidade { public string nome { get; set; } public object casas {…
-
3
votes4
answers1252
viewsWhat are ASAX extensions for?
Finally, I started working with C#. I am working on a SITE project and I am using Visual Studio. I came across a file where apparently you should put the global settings there, which is the…