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
-
0
votes3
answers59
viewsSave BD register
Hello, I am having a write problem in Sql Server, I have two tables(post and user), when I try to save the C#record, the error appears: (System.Nullreferenceexception: 'Object Reference not set to…
-
0
votes2
answers138
viewsPopular class with json
I got this json coming from my service { "CorIndicador":"VERMELHO", "DadosIndicador":"{\"Previsto\":25784.686452608872,\"Realizado\":95258.9557949728}", "TipoIndicador":1 } And I got that class…
-
0
votes2
answers53
viewsSend Post with Template data that attributes are classes
I’m trying to send a Post through a form, but in the controller the attributes that are classes are arriving as null, as I should do so I can get the data right so I can register in the database?…
-
0
votes1
answer60
viewsWhat’s wrong with this form?
Guys, I have an Asp.net mvc application that will only have a single page, which is index.cshtml. On this page I have a contact form, so he is not sending the captured message to my email, someone…
-
0
votes1
answer90
viewsError Entity Framework WPF Client
I installed my application in client environment but am getting the following error: Nome do Evento de Problema: CLR20r3 Assinatura do Problema 01: eLogBook.exe Assinatura do Problema 02: 1.0.0.0…
-
0
votes1
answer41
viewsSubmitchanges() does not update data in Linq
internal bool AlterarCargo(string login, string Categoria) { db.Log = Console.Out; //tentei ativar para ver se encontrava o erro mas não ajudou nada. var categoria = from x in db.Categorias where…
-
0
votes0
answers55
viewsc# Difference calculation dates with point separator
I’m trying to calculate the difference between two dates and times, the format they appear in the file is: day-month-year hour Example start time 17.11.17 22:55:12:968 end time 18.11.17 00:31:35:974…
c#asked 6 years, 9 months ago Jose Gonçalves 1 -
0
votes1
answer138
viewsHow to create Checkbox dynamically with windows Forms?
I have a list that returns from the database and for each record I need to create a checkbox of dynamic form, I did a search and found some examples for Webforms and I need an example for Windows…
-
0
votes0
answers94
viewsError creating installer by Visual Studio 2015
Good evening guys, I’m creating an installer of an application that uses Sqlite database, at the time of compiling the installer, it displays a Warning stating that SQL Server is required with some…
-
0
votes1
answer126
viewsdatabase backup
I looked in some tutorials here on the site, but I did not find one that fits what I’m looking for, so I followed this tutorial Backup & Restore Sql Server database in C# it even has a link in…
-
0
votes3
answers182
viewsError submitting form with ASP MVC
I am facing a problem submitting a form developed in ASP MVC. By clicking the save button the following error message is returned: System.InvalidOperationException: 'Não existe item ViewData do tipo…
-
0
votes2
answers157
viewsCreate a Join between two classes in my repository
I have a repository for my class PessoaCadastro that relates to the class Pessoa. I need to create a method GetJoinAll(...) show me all the table records PessoaCadastro that are related to Pessoa…
-
0
votes1
answer124
viewsValidate attempted fraud when editing record with C# MVC
In my applications was leaves the entity ID inside HTML being a hidden object. Example: @Html.HiddenFor(m => m.EntidadeID) But, I identified that I can edit HTML easily and in POST I can receive…
-
0
votes1
answer1150
viewsTurn Httpresponsemessage return to JSON
My API currently returns database values in JSON. If no value is found, I return one HttpResponseMessage with error code 404. However, when testing the request, only the message contained in Content…
-
0
votes1
answer4944
viewsHow to consume webAPI REST ASP.NET MVC
Good is the following, I am developing a service Rest and an application that will consume this web-service (VIA BROWSER SAME). In my project, I have the model (in this case my Oracle database), My…
-
0
votes1
answer206
viewsScraping an External Html
I’m trying to get a text from another site using C# (Htmlagilitypack). I can find the div, but when I try to show the value on the screen, it shows the path of the function. I believe I’m forgetting…
-
0
votes1
answer198
viewsRecover data from View Asp.net
I have following problem, when I place an order in the quantity field when I place a certain number I have to arrive if I have in stock in the bank, and if I have to reduce the quantity in the…
-
0
votes1
answer215
viewsEntity Framework Asp.net mvc data comparison
I need to receive the value and quantity in stock of a particular product according to your Id.By debug the product id is arriving correctly, but when I am going to assign the values to the table…
-
0
votes1
answer43
viewsHow to create an array the same size as another array without copying it?
private void InversaoString(string Texto, int Tamanho) { char[] arrChar = Texto.ToCharArray(); char arrChar2; int indice = 0; for(Tamanho = arrChar.Length-1; Tamanho>=0; Tamanho--) {…
-
0
votes1
answer2152
viewsSimple App C# console in Visual Studio 2017, closes without showing the result
I’m trying to run a simple program that writes "Hello world" on VS2017: namespace OlaMundo { class Program { static void Main() { int num; System.Console.WriteLine("Número :"); num =…
-
0
votes1
answer39
viewsProblems with hotkey to open and hide the interface using "Application.Current" (C# WPF)
The following code works without problem I made it based on the code available on the internet of Sirmestre, however it only opens/closes the Mainwindow UI, I have tried some things to work but…
-
0
votes1
answer246
viewshref with Submit on Asp.net core MVC
I have a _Loginpartial view in which you have a link to QUIT (Logout system). <li role="presentation"> <a href="javascript:void(0)" role="menuitem"> <i class="icon wb-power"…
-
0
votes1
answer57
viewsRead download data using Backgroundworker Progresschanged
td well? I am very new in programming, I took a project of a Auncher with autoupdate already ready and just edited some things. It basically downloads a game’s updates. I’ve handled other projects…
-
0
votes2
answers170
viewsSwitch only enters "default"
When I read a number, converting it to Int32, my switch simply understands that it is a default and makes the code there described. static void Main(string[] args) { Jogador j = new Jogador();…
-
0
votes0
answers603
viewsShow Total order value on View Asp.net mvc
I have a View Index where I will show the name of the store the order total and sum all orders and show the total value. I created a Reportstore. I can get total orders. In my table it is already…
-
0
votes0
answers385
viewsSqlbulkinsert- Import Excel Spreadsheet
I have a dotnet application to import spreadsheet, but I don’t know why I’m not able to enter the information in the database. My code is below. using System; using System.Collections.Generic; using…
-
0
votes1
answer83
viewsSeed Method for Many-to-Many Relationships
I am developing a simple application in MVC using Entity, being of registration of products, I am using the metodo seed to insert the values in the table, but in the relationship Many-to-Many I…
-
0
votes1
answer84
viewsHow to bring all items that have no reference with a given table [SQL]
I am using Nhibernate to make a query in sql in C#, but I have a doubt. I have the following structure: public class Pessoa { public long Id {get; set;} public string Nome {get; set;} } public class…
-
0
votes1
answer44
viewsError while backing up wpf c#
I am having trouble performing backup on my system. I’m using WPF with SQLSERVER 2008, on that system I need to backup the data on the client’s local machine, then I’m creating the backup directory…
-
0
votes0
answers361
viewsProblems with Javascript accentuation - Asp.net Core
Every text I write in Portuguese on buttons, etc, gets problems of accentuation in javascript. What I need to do? //Trecho do meu arquivo _Layout <!DOCTYPE html> <html class="no-js…
-
0
votes1
answer73
viewsService being null in controller
When performing a post for my controller, when debugging, I saw that the service I load in my constructor, is coming type null. Controller: public class UserController : ApiController { private…
-
0
votes1
answer160
viewsHow to resize the font size - WPF?
The following code works with winforms: while (label1.Width < System.Windows.Forms.TextRenderer.MeasureText(label1.Text, new Font(label1.Font.FontFamily, label1.Font.Size,…
-
0
votes1
answer48
viewsCreate List of actions already passing the parameters and then run them as parameters passed
I wanted to know if there is the possibility of creating a list of Actions already passing its parameters to execution, because the number that I will pass to the execution of the same can be…
-
0
votes0
answers235
viewsSystem.Data.Sqlclient.Sqlexception Conversion failed when Converting date and/or time from Character string
Viva Pessoal, I’m new to the world. NET, C#, Entityframework (Microsoft world). I am working on a project with the mentioned technologies, initially I was programming on a VM (with Windows) because…
-
0
votes1
answer166
viewsProblem with form Ubmit
I’m having trouble trying to make a form Ubmit when my object is null as it is not required. However it is not possible to save with it null. /// Model public class Atividade { public virtual long…
-
0
votes1
answer272
viewsReferencing non-static object in a static method
Good evening, I need to reference a component PlaceHolder Asp.Net in a static method in the code-behind C#, this method is called via AJAX for front-end see the code: Method call by the Form aspx…
-
0
votes1
answer535
viewsCall Action as parameter in Html.Beginform - ASP . NET MVC 5
I have a code that queries a Webapi, writes to the database, and queries the database, in this application, a view that has 3 buttons, namely: Consult Ws Inserts BD Comic book consultation I am…
-
0
votes2
answers284
viewsConvert number c#
How to convert R$3,852.00 and save in these bank . and ,? Follow my code. public ImportProcesso() { ImportProcesso processo = new ImportProcesso(); processo.dataReqPgto = new System.DateTime();…
-
0
votes1
answer433
viewsWPF select all Datagrid Checkbox
Hello, I’m trying to select all Checkbox of a datagrid but I’m not succeeding. Below is my code to select: private void CheckUnCheckAll(object sender, RoutedEventArgs e) { CheckBox chkSelectAll =…
-
0
votes1
answer121
viewsWhen I charge my App class is not recognized
It says that Badeview does not exist in the current context in this line of sham.g.Cs [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")] private…
-
0
votes2
answers329
viewsWhat’s wrong with my code?
I want to make a program that checks if any file is null but this casting an exception, which is wrong in my code?: static List<string> GetFiles(string path) { string[] directories =…
-
0
votes1
answer141
viewsSave time of registration in the database
I have a form and whenever someone register, I need to save the time of registration in my table Historico2 inside the property DateTime? Quando. public partial class Historico2 { public int ID {…
-
0
votes1
answer72
viewsError storing byte in mysql db
I am trying to store what I get in db mysql, however this giving error I think is type of error column: 26/02/2018 09:25:14 User connected 26/02/2018 09:25:14 Login : Skell 26/02/2018 09:25:14…
-
0
votes0
answers480
viewsSend complex view object to ASP MVC controller
In my View I have a complex model where I display in a table only a few fields. In this model I have another list called Tracks where I do not display its contents. Note the image below. I need to…
-
0
votes2
answers1024
viewsUpdate Updatepanel after running ajax without page refresh
Good afternoon, I need to update components that are inside a UpdatePanel page aspx after insertion via Ajax. The Ajax performs a function on code-behind in C#, and happens to reload the entire…
-
0
votes2
answers99
viewsStackoverflowexception in c# by Linux visual studio code
I’m trying to learn a little c#, and the microsoft website encourages me to use vscode for programming on linux, but I’m having a problem with Stackoverflowexception and I can’t understand why (the…
-
0
votes1
answer486
viewsInteger to String Conversion
I’m creating a cafeteria system. I created the login system and it’s working, when I went to create a page to create the logins, I’m having difficulties in converting the int for string - the…
-
0
votes1
answer182
viewsDoubt WPF C# - Setfocus on a Text and leave a button disabled
I’m having difficulty in c# because when I click a button, it has to disable a button and leave the Focus in a txt. But I don’t know how to reference an object in wpf (xaml) in the encoding file…
-
0
votes2
answers736
viewsSystem.IO.Ioexception: The user name or password is incorrect
I built an application using Asp.net where in a few moments of the application I need to access a directory and scan files and sometimes move and delete them. On my micro worked perfectly, but when…
-
0
votes0
answers39
viewsThe value change in the integer array in one index works in one case, and in another it doesn’t, why?
private void btnRodaLabirinto_Click(object sender, EventArgs e) { char[,] Lab = new char[10, 10]; int[,] Lab2 = new int[10, 10]; int I = 0, J = 0; Random NumerosRandomicos = new Random(); //abaixo,…