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
-
2
votes3
answers511
viewsWhat is the most recommended "Try" or "if"
{ public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double SalarioBase = 0, Descontos = 0, Vantagens = 0; try { SalarioBase =…
-
2
votes2
answers1012
viewsDrive with 2D Touchscrren
I need to make a C#Script code for moving a 2d character in Unity. I developed a code that runs well on the pc using arrows, but I have no idea how to make it move using the touchScren of an Android…
-
2
votes0
answers178
viewsError while removing data in Gridview Asp.net c#
Staff every time I try to remove a data on gridview I come across this error "The data source 'Sqldatasource2' does not support deletion unless Deletecommand is specified." this is my method of…
-
2
votes1
answer517
viewsHow to modify a window in Windows Forms?
How to change the appearance of Window borde, Title bar and button, and status bar in Windows Forms?
-
2
votes1
answer53
viewsIn terms of performance, what is the best way to declare a variable that will be used in multiple Actions/Methods in a class?
Which mode is best performatically speaking? Which way you recommend and why? //Modo 1 MeuManager mm = new MeuManager(); JsonResponse MetodoDOIS(string urlImagem) { var abc = mm.Lista(); }…
-
2
votes1
answer119
viewsTimespan conversion
I am reading a file delimited by semicolon and one of the information that is the duration of the link is coming as "00:97:54". When trying to convert to Timespan, obviously gives error The Timespan…
-
2
votes1
answer113
viewsSubquery with Linq
I need to consult with Linq on an object called Client. This object has a relationship with another object, which is a list of phones. For each of the phones, there is a type: 'Casa', 'Comercial',…
-
2
votes1
answer698
viewsHow to get Tempdata value with List<Object>?
Follows code: List<object> list = new List<object> { "abc", // string 1, // int true // bool }; TempData["ID"] = list; The following code cannot get value: var data = TempData["ID"]; var…
-
2
votes1
answer706
viewsDoubt with @Style.Render
If I put in mine view Layout that line: @Styles.Render("~/Content/css") I’m stating that all the files .css in the briefcase Content will be rendered? I mean, I don’t need to put any .css explicitly…
-
2
votes3
answers767
viewsUpload image to picturebox and write to database
I am now in the movies part of the video club, where I have these fields. And I wanted to upload the image to the Pictura box (it is already working) and when I made new it was saved in the database…
c#asked 7 years, 4 months ago Daniel Sousa 49 -
2
votes1
answer83
viewsConditional "on" and "off" on a C#
How to put a secondary function on a button or element? For example : private void Bnt1_Click(object sender, EventArgs e) { } private void Bnt2_Click(object sender, EventArgs e) { bnt.Enabled =…
c#asked 7 years, 4 months ago user61171 -
2
votes2
answers308
viewsHow to Include an Item in a Icollection
I have a class Person who has a ICollection telephone class. On the Person maintenance screen I have a datatable with the Phones. There is a link to add a new phone, but I can’t use the…
-
2
votes1
answer735
viewsHow to convert HTML to RTF?
I have an Asp.Net MVC project where I would like to convert an HTML string to RTF in Controller. I’ve tried the following ways: Source 1 using(var webBrowser = new WebBrowser()){…
-
2
votes1
answer279
viewsHow to assign a default date value to a Textboxfor?
I own the following Textboxfor @Html.TextBoxFor(model => model.data, "{0:dd/MM/yyyy}", new { @class = "form-control", @alt = "date", @placeholder = DateTime.Now.Date.ToString("dd/MM/yyyy"),…
-
2
votes2
answers4575
viewserror "Undefined object reference to an instance of an object." when displaying a null value in the view
Within C# MVC5, I am creating a user registration form with several fields. One of them is the Function (Bonus) field, which the user may or may not have. Follows the User class: public class…
-
2
votes1
answer87
viewsHow to read the IPTC header of an image through C#?
How to best read the IPTC header of an image ? I have the following image and I needed to read her description (for a database of images), but I have already researched many ways that for me were a…
-
2
votes1
answer1598
viewsValidation of RNE (National Aliens Registry) or CIE (Alien Identity Card)
Does anyone know how I can validate the CIE (Foreign Identity Card) or RNE (National Aliens Registry) number? I believe there are two names. Language-independent.
-
2
votes1
answer375
viewsWith export HTML string to PDF Compressed (zip)
I have this string: <HTML><HEAD></HEAD><body><FORM method="post"><table><tr><td>Nome:</td><td>JOÃO DA…
-
2
votes1
answer468
viewsLeft Join in LINQ
I have the representation of 2 classes. first class: using System; using System.Runtime.Serialization; namespace WebService { [DataContract] public class PessoaDados { private Nullable<int>…
-
2
votes1
answer91
viewsEntityframework Executesqlcommand not accepting parameter
I’m running the Executesqlcommand. In the right way, parameter doesn’t work: var SQL = "update POSTOFFICE set Status = 1 where name = '@url'"; dbMailEnable.Database.ExecuteSqlCommand(SQL, new…
-
2
votes1
answer271
viewsEntity framework Many-to-Many Ientitychangetracker error. How to resolve?
I have a Many-to-Many relationship and my tables are correct about the relationship in the database. The problem is that my insertion works perfectly when you don’t use an existing entity in the…
-
2
votes1
answer160
viewsLEFT Outer Join does not work on LINQ when 0 is the reference? null only
I’m having doubts on Left Outer Join, I’m using MVC 5 C#, Net 4.5.2. I have the following Model Fornecedor public class fechamentoFornecedor { public int FornecedorId { get; set; } public int Tipo {…
-
2
votes1
answer437
views@Html.Editorfor Datetime property remove hh:mm:ss
In my model have a field DateTime called Dating, I graduated with Attributes, but when I’m in view is filling in hh:mm:ss I just want the date 29/02/2016. Model [Column("sdt_DataReferencia")]…
-
2
votes1
answer183
viewsRun program in certain folder in IIS
I would like to know how to run an exe or jar program in a certain IIS folder, through the code c# . net core. It would have to be a synchronous call, that is when c# performs the call from the jar…
-
2
votes0
answers493
viewsHow to schedule tasks for a given time C#
I need method to perform tasks every day at the same time which class should I use for this type of task?
-
2
votes1
answer61
viewsMove button controls in a Windows Forms application inside a panel container
I have a form with three buttons, are they: btnVendas, btnFunctionaries, btnConfig. And they’re lined up inside a Panel container. I need these buttons to be clicked and held by the mouse pointer so…
-
2
votes1
answer2822
viewsHow to get all the HTML of this page as a string?
I’m doing a college job and with that trying to read the HTML of a Bradesco page(Link I want HTML here) The problem is that I can’t get the HTML inside the frames and I don’t know how to get it.…
-
2
votes2
answers1086
viewsTransform Json return to list of C#objects
I have a request for an API that returns the following JSON:…
-
2
votes1
answer345
viewsChosen ASP.NET MVC plugin
I’m trying to use the plugin chosen (http://harvesthq.github.io/chosen/) with the DropDownListFor, but when using this plugin the field validation not working. Box.cshtml @model CaixaViewModel…
c# asp.net-mvc validation chosen-jquery-pluginasked 8 years, 7 months ago Pablo Tondolo de Vargas 5,444 -
2
votes1
answer68
viewsQuery with Parameter causing timeout
I have a query that when running with ADO.NET it takes less than a second to return your data. When adding Parameters to this query, the return remains the same. However, when adding a type…
-
2
votes1
answer594
viewsLinq + Lambda, sub-query, distinct and not in, how to improve this query
I had the following syntax in SQL SELECT tbl_boleto.int_IDC, tbl_Admin.int_STATUS, tbl_Admin.int_CONVENIO, tbl_Admin.int_PLANO, tbl_Admin.int_RESTRICAO, tbl_Admin.str_URL FROM tbl_boleto INNER JOIN…
-
2
votes1
answer637
viewsCommunication with Siemens PLC
Soon I will be developing an interface with Siemens PLC, model ET-200A. This is a new subject for me and here I am with some doubts. Has anyone ever dealt with that kind of communication? The…
-
2
votes2
answers804
viewsGenerate text file from a console application
I need to adapt this method of an application Windows Forms https://github.com/BoletoNet/boletonet for Console Application, that is, instead of using the object saveFileDialog.ShowDialog() I have to…
-
2
votes2
answers127
viewsLoading Grid data with Checkboxcolumn
I am creating a form to perform a registration for a product license. This form is used to record which solution a customer has. In the form to add a product just select product and the client. I am…
-
2
votes1
answer809
viewsTree View hierarchical Dynamic C#
I have the following situation, my select returns me 3 fields micro (son), descend(descend from the child) and macro(parent) micro and macros fields are integers and can be any number not following…
-
2
votes2
answers973
viewsInheritance X Composition - Mysql C# Entity
There was a doubt of inheritance modeling in C# involving the entities Pessoa, Pessoafísica and Pessoalegal, but Gypsy Morrison Mendez helped a lot! Now I have another question in another type of…
c# asp.net-mvc entity-framework inheritance compositionasked 8 years, 7 months ago Felipe Bulle 387 -
2
votes2
answers352
viewsHow to receive the view model in a GET request Webapi?
Okay, I have a problem with my API here, and I’d like to ask for your help. I have here a form in Knockout JS, I serialize a constructor that in turn returns me a querystring so API?…
-
2
votes2
answers689
viewsCall for generic methods in C#
I built a generic method that suits me well, but I’m having difficulty in calling this method. public List<T> CriaLista<T>(params T[] pars) { List<T> lista = new List<T>();…
-
2
votes1
answer734
viewsMVC - Creating a typed model as a generic list
I would like to create a typed model being a list of the type T. Utilizing: Razor from ASP.NET MVC 5 For example: My model in the cshtml will look like this: @model List<T> @foreach (var item…
-
2
votes2
answers246
viewsString for Keyvaluepair using LINQ
I am receiving a string in the format "N1N2S3S4L5L6O7O8X" and I need it passed to a KeyValuePair or for a NameValueCollection. Where the key is the letter and the number the value. { N, 1 } { N, 2 }…
-
2
votes1
answer339
viewsIntegration of Web Service Information
I’m having a little trouble making a Web Service. I have a database Mysql simple to register people. I already have my methods for performing operations CRUD ready in a classe . that were used in an…
-
2
votes1
answer466
viewsRMI equivalence (Java) in C#
What is the equivalence of RMI (Remote Method Invocation - Java) in C#?
-
2
votes1
answer439
viewsStore vector in Sqlite
I am creating an application in C# that must have a database. At first I’m thinking of using Sqlite for simplicity. But for each data entered in my bank must have : Identifying (int, char, bool)...…
-
2
votes3
answers393
viewsSort children in consultation Linq
I’m having trouble making an ordination in a query where I have to sort the children by the ID, Follow the Source. public Grid GetByOrderGridData(long id) { var query = from c in…
c# asp.net-mvc entity-framework linq lambda-expressionsasked 7 years, 3 months ago Thiago Ubiratan 353 -
2
votes1
answer169
viewsIs outputcache only valid at controller level?
I’ve been reading the article: http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs And I started using the: [OutputCache(Duration =…
-
2
votes2
answers576
viewsIntegration of two different applications in ASP.NET MVC
Hello, I need to integrate two different applications: one is a client business administration application and the other a financial management application. They are two separate applications, so…
-
2
votes3
answers192
viewsFormatting with UNION and LINQ in C#
I am using the following code to bring a list of companies with CNPJ formatted for Datagridview: dgv.DataSource = db.pessoajuridica .Select(d => new { d.idPessoa, d.nome, d.cnpj })…
-
2
votes2
answers1655
viewsCreate spreadsheet by C# without having excel installed
I am developing a program that should export data to an Excel spreadsheet. I need to know how to build a spreadsheet with C#, but only found tutorials that require excel installed on the computer. I…
-
2
votes1
answer777
viewsOperation of Request.Files;
I have an Asp . Net MVC project, with a form on View which sends files to the Controller. In control I recover the files as follows: var myFiles = Request.Files; Not saving the file, just reading…
-
2
votes1
answer1139
viewsWeb API - Token
A MVC application accesses WEB API services. To access the WEB API it is necessary to inform a "token". In the WEB API application there is a button that generates the token. How to make the WEB API…