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
votes1
answer31
viewsNavigationbar Visualstudio 2013
Today I started a project in C# and realized that in the navigation bar, when I click on a control I am directed to the designer of . aspx, and is not displayed the events that the control has as in…
-
3
votes1
answer196
viewsHow to call another class column name in Webgrid MVC
I have this view Listar.cshtml @model IEnumerable<ODM> @{ var idGrid = "grid" + this.ViewBag.IdParameters ?? string.Empty; var grid = new IBM.Web.Helpers.WebGrid(id: idGrid, rowsPerPage:…
-
3
votes1
answer1030
viewsConvert String to monetary value in ASP.NET MVC
How to convert the result of a multiplication into a string to display as Real? The value of bol.ValorBoleto is loaded just before. To data Annotation: [DisplayFormat(ApplyFormatInEditMode = false,…
-
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
answer478
viewsA dynamic field for each database record
I have a property called Productdevelopment where I have several functions and must assign a user to each function. I have an Editortemplate to return a list of users. I have to create a dynamic…
-
3
votes1
answer331
viewsSave Operations log to database with system user field
Hello, would like to know how to by means of triggers in the bank I get beyond saving the operations performed and in which table held also the user logged into the system (not the bank user, if the…
-
3
votes1
answer357
viewsFluent Nxn mapping of Classes with composite key
I have two classes that have composite primary keys, example: Cliente: public class Cliente { public int EscritorioId { get; set; } public virtual Escritorio Escritorio { get; set; } public int Id {…
-
3
votes0
answers235
viewsWeb API C# - Validate token generated by another server
I have a basic Oath api, it only generates the token, it is on localhost:1010/Token I have an api with the business rule methods, is on localhost:2020/api How do I validate whether a token is valid…
-
3
votes3
answers1160
viewsValidation to check if the record is being used before deleting
The MVC of my project is stuccoed in services, controllers, Views and models. My deletion screen works, but when the record is used in other tables it displays this error. The DELETE statement…
-
3
votes1
answer588
viewsMy software is being blocked by Windows Smartscreen
I am developing a software and, while testing the executable on another computer gave me this message from Windows Smartscreen. I don’t know what it’s about, I’ve done some research and I haven’t…
-
3
votes2
answers145
viewsdataGridView1_CellDoubleClick does not work!
I have the simplest function in the world and I can’t make it work. By giving 2 clicks on any cell of my datagridview I want to display the message "1" but it’s not working! What’s wrong? Look at my…
-
3
votes1
answer1291
viewsThe method or Operation is not implemented error
When I will add a record on my Include screen, I get this error. What can it be? Service public void AddItem(Test item) { var codigos = this.context.Tests.SingleOrDefault(x => x.Codigo ==…
-
3
votes1
answer216
viewsHow to return a message together with an Httpstatuscode
I have the following method in my Controller: public IHttpActionResult Get(string id) { var product = objds.GetProduct(new ObjectId(id)); if (product == null) { return NotFound(); } return…
-
3
votes1
answer339
viewsHow to use a Masked textbox for C#time?
I’m trying to create a Masked textbox that gets the time of a video. But I don’t know how to format the Masked textbox to get the time in HH:MM:SS:MMM. The value of the time I get from the video is…
-
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
answer199
viewsUpdate Mongodb in array
{ "_id" : "55dcb404478e7227203d3a65", "Nome" : "Grupo Familia", "Pessoas" : [ { "PessoaId" : "55dcb425478e72207833e970", "Nome" : "Carlos", "Habilidades" : [ { "HabilidadeId" :…
-
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
votes1
answer211
viewsWhen mapping class to viewModel, some data is lost
I have an appointment that returns a client and his phone, but when mapping the class to the viewModel, I lose phone data: consultation: public Cliente ObterClientePorId(Guid ClienteId) { var…
-
3
votes0
answers33
viewsSharestatustask identify my app on Facebook?
I’m using the code Microsoft.Phone.Tasks.ShareStatusTask status = new Microsoft.Phone.Tasks.ShareStatusTask(); status.Status = "Eu, " + sNome + ", sou doador de órgãos, baixe o app e seja um também:…
-
3
votes1
answer1201
viewsError after configuring Authorization on Web.config
I’m having trouble accessing the MVC application right after setting up in Web.config to authenticate with the windows user. Error occurs when enabling the following line: <authentication…
-
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
answer49
viewsI can’t add a Ference
I am doing a project for the school in C#, with database and Mysql. When I try to add the extension Mysql.Data it simply is not added. I’ve installed Mysql Connector, I’ve seen hundreds of tutorials…
-
3
votes1
answer672
viewsDbupdateexception exception
I am trying to study EF with Code First. I am getting this exception on SaveChanges() An unhandled Exception of type System.Data.Entity.Infrastructure.Dbupdateexception occurred in…
-
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
votes1
answer916
viewsHow to center text using print Document c#?
I’m making an impression and would like to center the text using this code on printpage e.Graphics.DrawString("bla bla bla bla", FontTitulo, brush, e.MarginBounds); How do I center?…
-
3
votes2
answers254
viewsScaffold MVC Template Editing. How to get project reference in Solution Folder?
I am editing the T4 templates from ASP.NET MVC’s Scaffold and I need to get some extra class information. At first, for example, of the attribute DisplayName class. I found some examples: var env =…
-
3
votes1
answer785
viewsMount one HTML table from another’s records with Jquery and C#?
I need to compose/generate a new table in html where the records of the new will come from a selection of <input type checkbox> in another table on the same html page displayed in a modal, see…
-
3
votes1
answer390
viewsEnter additional data, from the bank, into the user’s Claims. What is the best time or the right way to do it?
I have some extra information that I need to add to the user’s Claims that are from other tables and classes. Considering the method generated by the ASP.NET MVC template with Identity in the class…
-
3
votes4
answers1114
viewsCreate string array in C#
There is a way to create an array of string constant? Something like: class Teste { public const string[] Array = new string[] {"a","b"}; } But this one doesn’t compile. In this case nay would…
-
3
votes1
answer455
viewsConsult in several fields of the record in a single query
I am developing an item list filter, and would like to filter by any term of the item record. I’ve seen this work in Angular, but I’m developing for ASP.NET MVC 5 and using the Entity Framework +…
-
3
votes1
answer184
viewsViewdata["Errormessage"] does not appear in view
Hi, I’m new to c# and would like to know why my Viewdata["Errormessage"] does not appear in my view. Controller: ViewData["ErrorMessage"] = "O e-mail digitado já se encontra registrado em nossa base…
-
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
votes1
answer233
viewsAsp.NET Asp Click Error:button
I have a screen where I have some buttons and clicking on the buttons returns me the error on the screen: "Index was out of Range Must be non-negative and Less than the size of the Collection." The…
-
3
votes1
answer468
viewsSignalr - Messages for multiple hubs
I am using Signalr in a C# web application with VS2015. This application has 2 pages A and B. Who accesses page A connects to the "paginaA" hub and who accesses page B in the "paginaB" hub. This way…
-
3
votes2
answers265
viewsError Nhibernate System.Invalidcastexception - Manytoonetype to Componenttype
Exception: System.Invalidcastexception: It is not possible to convert an object of type 'Nhibernate.Type.Manytoonetype' to type 'Nhibernate.Type.Componenttype''. The classes involved are: public…
-
3
votes1
answer890
viewsAlignment of cells in itextsharp
I have a problem and I can’t find a solution, I am using itextesharp in a windowsfroms application, I created a table with 7 cells and I would like to align some right and others centralized.…
-
3
votes1
answer1210
viewsQuery using the Entity framework
Within my repositorioEF I have the methods, in the method ExcluirRegistro I’m passing a StatusRegistro for the bank indicating that this record is being deleted, then in my methods ListarPorId and…
-
3
votes1
answer148
viewsController dependency injection with Ajax
Good afternoon, I am using ASP.NET MVC 5 with Windsor and when an Ajax request calls a method in the controller, the error informing that the controller has unsatisfied dependencies. How do I work…
-
3
votes1
answer1470
viewsHow to get value from a variable in the controller with ajax(jquery)
I have to take a value from a variable within a method in the controller on . net, the method is in homeController and returns a json, up to there everything well the code is running and returning…
-
3
votes2
answers163
viewsConvert Switch to IF
Hello everyone is the following I have this code and I needed to change it to if instead of switch, how can I do this? switch (theOperator) { case "+": total2 = total1 +…
-
3
votes2
answers234
viewsAdding Text Box and Writing to Database. (with C#, entityframework 6.1.3)
I am doing a project in Visual Studio 2013, with Entityframework version 6.1.3, MVC 4.5.0.0 and using Viewmodel. I am programming a page that is called payment condition. The creation page will have…
-
3
votes2
answers100
viewsHow to manipulate title="" by c#?
It is possible to put the text of the title="" attribute by c#? The title I intend to manipulate is: <asp:HyperLink runat="server" ID="linkTitle" CssClass="link_title search-result-link-title…
-
3
votes0
answers1328
viewsAPI for Secure Notifications
Gentlemen, good night! I’m doing an integration with pagseguro for my site. I set the page to receive the notification whenever its status is changed according to the code below. protected void…
-
3
votes1
answer145
viewsIgnored await in asynchronous method c#
I need to use the return of an asynchronous method for validation but even with the use of "await" the method is still running before I receive the return of the function. var teste = await new…
-
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
answer237
viewsRemove EF dependencies without using the Myconfiguration class
I am trying to create an application by removing all EF dependencies and leaving only the necessary layers: Repository and Applying. I did a small project to test the operation before applying in…
-
3
votes0
answers792
viewsC# I have a Steam swap bot and it returns the error "Undefined object reference to an instance of an object"
I searched all the other topics and saw several answers but I can’t apply them to my application because I don’t know anything about C#... My site is CS:GO betting and I have a C# bot that works as…
c#asked 9 years ago Marciel Fonseca 203 -
3
votes1
answer887
viewsSending via Formcollection of monetary values
I need to send to a method in Controller, the values filled in the column Payment_value as shown below: By clicking the green button, send via post, the values of the list below that generated the…