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
votes2
answers581
viewsGet the ID of a line from a Gridview query
I made a query where it is populated a gridview, the columns are code, category, noprazo, foradoprazo. In the columns noprazo and foradoprazo, I left them as linkbuttom that by clicking on the…
-
2
votes2
answers213
viewsTreat return in class in C#
I have a class Table: public class Mesa { public int Cdmesa { get; set; } public int Flsituacao { get; set; } public string Status { get; set; } } I would like to return the Status with the…
-
2
votes1
answer108
viewsRequired validating property of another object
I have the following properties, however when I will validate via Modelstate.Isvalid returns that the description of the user group to be informed that it is User too, but the problem is that I am…
-
2
votes1
answer170
viewsHow do you fix columns on a Listview?
I got the following Listview below, precise leaves the first 3 columns fixed and allow the rest to scroll. <td colspan="4"> <div class="GradeDados" style="position: relative; width: 1000px;…
-
2
votes1
answer381
viewsHow to deserialize JSON with C#
I have this JSON [{ "new_as_cod": "0010955", "as_nome": "NAME", "as_cpf": "1212121212", "as_email": "[email protected]", "as_cep": "88.025-200", "igr_nome": "1\u00aa IGREJA BATISTA - FLORIANOPOLIS",…
-
2
votes3
answers2520
viewsSearch for file with only part of its name in C#
I need to find a file automatically without opening a check box for the user to select the file. Where I already have the directory of the folder where this file will stay and I also know the part…
-
2
votes1
answer156
viewsNot In Linq Sql Entity Framework
I need to do Nessa research, but presents the error: ambiguous Invocation. public List<Notification> Get(List<UserVisualization> item) { return db.Notifications.Select(o=>…
-
2
votes2
answers459
viewsSend parameters to a C#interface
I created a class called descricaoo that will receive some data parameters and will add in a List of an interface called IInstrucao. But give an error "the descricaoo class is not implemented to an…
-
2
votes2
answers1051
viewsCopy data from one field to another
My client, requested that I create 2 fields in the system, one as "Cellular" other as "Whatsapp" and that next to the Whatsapp field had a button to copy the value, if the number is the same,…
-
2
votes1
answer120
viewsGenerate the primary key in the application or keep it auto-incrementable?
Should I set the primary key of my table as auto_increment or define it as numerical, generating the key within my application? Contextualization I am developing a C# application and testing it in…
-
2
votes1
answer158
viewsLINQ TO XML Query with Optional Widget
Hello folks I’m having a question to display the data of a file XML through a consultation LINQ , the problem is that I am trying to consult the data of the person but the mandatory filling and name…
-
2
votes1
answer866
viewsHow to access a list of another class in C#
I’m trying to access the Contact Contact List list in the Contacts List class to view. The problem is that although the list is filled in Contact, in Contacts Lists it appears empty. public class…
-
2
votes1
answer564
viewsComparison of Object Lists - C#
I need to compare 2 lists of objects that were populated via database, as classes below: public class Ausente { public ObjectId Id { get; set; } public Int32 RA { get; set; } } public class…
-
2
votes2
answers1102
viewsError while converting HTML to PDF
I need to make a PDF from a page HTML, but while converting I get the following error: Cannot convert an object of type 'iTextSharp.text.html.simpleparser.Tablewrapper' to type…
-
2
votes1
answer236
viewsIs using the oid column in Postgresql as the primary key correct?
Postgresql creates by default the Oids column (object identifiers), you can get it by doing. select oid, * from table Problem that I have a table that has no primary key, and I want to map it in…
c# postgresql nhibernate fluent-nhibernate primary-keyasked 7 years, 10 months ago Marco Giovanni 2,768 -
2
votes1
answer1483
viewsCreate a mock for any instance of a class
How do I mock any instance of a class? I would like to do this so I don’t have to mock an object and have to put it inside a class. Example: [TestFixture] public class TokenTest { GeradorDeToken…
-
2
votes1
answer1235
viewshow to select Count using Linq C#
I need to convert this chunk of SQL code to Linq C#. I’ve been able to convert virtually every code. SELECT COUNT(Q.ID_QUALIFICACAO) AS CONHEC_ESPECIFICO FROM QUALIFICACAO Q INNER JOIN ATENDIMENTO A…
-
2
votes1
answer965
viewsHow to upload a file at the same time as sending an Asp.net mvc 5 form
I already have a form that makes a registration, I want to add an extra field in it where the user will upload a photo, I want to do everything in the same Ubmit. My VM Vmdominiocreate: public class…
-
2
votes1
answer41
viewsPost com form + string
I own the following Function: var form = $("#formEditarCompra"); var meioPublicacao = $("#MeioPublicacao").val(); if (form.valid() && setarFocoErro()) { mostrarAguarde();…
-
2
votes1
answer384
viewsPass data from one form to another class
I have very cute Form1 with very cool button and inside it I have a toggle button on-off. I have another class.Cs and I have a condition in it, but it will only perform if that boot there on Form1…
-
2
votes1
answer102
viewsCalculated field with RU
I have two classes : public class Cliente { public int Id {get;set; public string Nome { get; set; } public string Email { get; set; } public string Telefone { get; set; } public string Celular {…
-
2
votes1
answer52
viewsWhat am I doing with this method?
I have the following method: [HttpPost] [ValidateAntiForgeryToken] public async Task<ActionResult> Criar([Bind(Include = "CategoriaId,Nome")] Categoria categoria) { if (ModelState.IsValid) {…
-
2
votes1
answer220
viewsImage stored in the bank is not displayed in the View
I’m trying to display an image that’s stored in the database. When the Photo (Image) field of the table is null, I display a default image that is stored in the directory. The problem is that the…
-
2
votes1
answer1247
viewsHow to take the Dropdownlist ID and move to a jQuery variable?
I have the following Dropdownlist: <div class="editor-field"> @Html.DropDownList("ProdutoId", String.Empty) </div> And this jQuery function that when the user presses the button will…
-
2
votes2
answers800
viewsSlow SQL LINQ C# Entity Framework problems
I am using Entity Framework, I have a list of objects (data taken from the database) with data from Clients, public virtual DbSet<clientes> clientes {get;set;} public…
-
2
votes2
answers2268
viewsWhat is the difference between Tolistasync() and Tolist()?
What difference between ToListAsync() and ToList()? As in the example below, what is the difference between one and the other? using Modelo.Classes.Contexto; using System.Data.Entity; using…
-
2
votes1
answer64
viewsWrite file to database with Nhibernate
It is possible to serialize and write file in database with Nhibernate? public virtual File Arquivo { get; set; } He does not let map and did not want to record without using Nhibernate to follow…
-
2
votes1
answer1089
viewsSave image in Xamarin Forms
How to save the image from BD in any existing folder in the project ? I need to create a new folder or save the image to any folder inside the app in order to use it in one View. My code: byte[]…
-
2
votes1
answer429
viewsHow do compiler recognize . as decimal separator?
I made a simple code in C# that receives a real number but only recognizes "," as a decimal separator. When I make you receive numbers that use "." as separator it ignores the point. For example, if…
-
2
votes2
answers814
viewsMonitoring internet connection at runtime
I’m using this method in C# to be able to identify whether or not the computer is connected to the internet private bool VerificarConexao() { if (NetworkInterface.GetIsNetworkAvailable()) { return…
-
2
votes1
answer346
viewsProblems generating a Partialview with Begincollectionitem
With the intention of creating an action for Adc/Delete data dynamically to a table with relation 1 to Many, the . net returns the exception "Undefined object reference for an object instance." when…
-
2
votes1
answer414
viewsHow to connect to SQL Server with VB.NET?
I’ve tried like five tutorials. See the code in C# string minhaString = "Server=.\\sqlexpress;Trusted_Connection=true;" + "Timeout=10;" + "Database =bdcadastro;"; SqlConnection minhaConexao = new…
-
2
votes2
answers190
viewsConnection String Error in Visual Studio 2015
When I place the connection string, the following error appears: Con = new SqlConnection("Data Source=(localdb)\MSSQLLocalDB;OutrosParametros"); Represents text as a series of Unicode characters…
c#asked 7 years, 9 months ago Jefferson Souza 379 -
2
votes1
answer48
viewsUniversal Apps 8.1 on Windows 10
Does Windows 10 have backward compatibility with Universal Apps from Windows 8.1? That is, applications written in for Windows 8.1 run on Windows 10?…
-
2
votes1
answer159
viewsHide form through C#keys
I’m making a menu in c# and the same only opens when the game is open or running, IE, if the game is running show the menu, so everything well it performs, but I wanted to hide the menu for example…
-
2
votes1
answer243
viewsJavascript function does not run Pagemethod
I’m calling a Pagemethod in a Javascript function, but it goes straight to the end not entering my function C#. Follow the code below: <script type="text/javascript"> function enviar() { if…
-
2
votes1
answer895
viewsView passing date to Model in wrong format
I’m using Bootstrap-Datapicker as date field in my form and globalizing with moment-with-locales. The configuration I used is as follows:: $('.datetimepicker').datetimepicker({ locale: 'pt-br',…
-
2
votes3
answers3848
viewsI can’t connect localDB with visual studio
I’m trying to use the Entity framework in Visual Studio, but when I try to run the program generates the error: System.Data.SqlClient.SqlException was unhandled Class=20 ErrorCode=-2146232060…
-
2
votes1
answer59
viewsSearch form does not execute controller method
I have the following form: <form role="search" method="get" id="search-form" name="search-form" action="/video/pesquisa"> <div class="cover-pursuit-btn"> <button type="submit"…
-
2
votes2
answers79
viewsColor Visualization and New Creation
I need to make use of the class Colors defined in namespace Windows.UI. There are many colors available and I need to find a way or place to see a preview of these colors, because only by name it is…
-
2
votes1
answer89
viewsWindows service for after Exception
Is there any way to make a Windows service created on c# don’t give Stop() after a Exception? The service was created with a timer, which will run every 1 hour, but there was an error in the…
-
2
votes3
answers1955
viewsHow to scan data from an Excel spreadsheet
I have a Mysql database and I want to take the data from an excel spreadsheet and send it to him. I already know how to save the data in the table, just need to know how to scan the spreadsheet and…
-
2
votes1
answer94
viewsAuto-update of Publish in Visual Studio zeroing the database
Soon I had to create an installer for desktop application in c#, and as in visual studio 2013 there was Publish that already created Setup and Auto-Update I ended up using it for convenience, but…
-
2
votes1
answer287
viewsMerge two Word documents
I have a problem and would like a force, I have a project but I have no code to include my question. Client is requesting a button that joins 2 or more. docx files and turns into 1 only or sends to…
-
2
votes1
answer404
viewsHow can I validate an Enum using Fluentvalidator?
I’m creating a validation class in c# using FluentValidation to validate that my property Type of my class Account be the type AccountType which is mine enum. How would the correct implementation of…
-
2
votes1
answer208
viewsAggregations and the DDD
I’m developing a project applying the principles of DDD, I created a class aggregation (Conta) it will contain the classes (Agencia) and (Agente) that as (Conta) have tables in the database. My…
-
2
votes1
answer1166
viewsDapper Framework Error: Could not load file or Assembly 'Dapper, A strongly-named Assembly is required
Hello, I use Dapper Framework to perform my SQL queries in C# Windows Forms, and recently started a new project, and came across this error: Could not load file or Assembly 'Dapper,…
-
2
votes1
answer86
viewsJsonconvert returns Exception in Xmlnode
I tried to convert Json to Xml so making it easier to read. And I used the following code... using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using…
-
2
votes1
answer426
viewsInstantiate class or use public methods?
When using a class method, there are two approaches: instantiating the class and using the method by the object, or making the method public static and call directly. Is there a problem using one or…
-
2
votes1
answer1215
viewsTransfer network files C#
I wonder if there is any way to transfer files on a local network without using the Socket Class in C#? and in terms of performance what is the fastest method of transferring files over a local…