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
votes2
answers439
viewsWrite data to the database (Value Member and Display Member)
I am having trouble writing this data into the database (Postgresql). In case the data you would like to save is: Customer Name Origin, Customer Name Destination, Order Date, Payment Date, Confirm…
-
3
votes2
answers868
viewsHow does Entityframework’s Tracking / Chache work?
Every time I used the Entityframework in a project, to add a record in the database through it, of a class that contains class type members (usually on account of Foreignkeys), I would do this:…
-
3
votes1
answer145
viewsError Connecting to Windows Phone 8.1 Silverlight Bluetooth Printer
Trying to connect to the Bluetooth Printer gives the following error. " No more data is available. (Exception from HRESULT: 0x80070103)". This error only came from Visual Studio 2013, in Visual…
c# visual-studio-2013 windows-phone windows-phone-8-1 silverlightasked 9 years, 4 months ago Natanael Ribeiro Ferreira 133 -
3
votes2
answers2482
viewsRepeat header in print
I can’t release the report I’m using, so I took a generic model on google to help me explain the doubt. Assuming my report is as follows:: It is mounted via HTML on a system that works with both C#…
-
3
votes2
answers1464
viewsI cannot read the values returned from the database using Oracledatareader
I’m having trouble reading the values returned from a select, on the line where I do: OracleDataReader reader = cmd.ExecuteReader(); in the read it brings me the values correctly, but in the next…
-
3
votes1
answer425
viewsEF6 Entityvalidationerrors error in filled property
I have a similar problem in two ASP.NET applications with Entity Framework. When I try to update an entity that already has all the required attributes filled I get an exception from…
c# mvc entity-framework-6 validation model-validationasked 9 years, 4 months ago Eduardo Barbosa Oliveira da Si 45 -
3
votes2
answers242
viewsDifferentiate Datetime.Now and Datetime.Now.Date
I have a test and would like to know when an attribute received DateTime.Now or DateTime.Now.Date, has how to differentiate when an attribute has received these values? Note: Can be varied values,…
c#asked 8 years, 10 months ago rubStackOverflow 7,372 -
3
votes2
answers576
viewsConvert Json to XML
I have that code: using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Diagnostics; using System.Xml; using Newtonsoft.Json; using System.Net;…
-
3
votes1
answer1017
viewsHow to display an ASP HTML code on a Label by sending by Code-Behind(C#) - ASP.NET
I’m having a problem, I did several tests where I wanted to send directly from a C# method an HTML code to a label, where it would display dynamically the code on the screen. But when I tell her to,…
-
3
votes1
answer545
viewsInputmask by the model
Hello, I’m using the plugin jQuery - maskedInput, where I take the id of my input and make the mask: $("#CPF").mask("999.999.999-99"); is working, only that would like to use this mask through the…
-
3
votes2
answers37
viewsDoubt with sql command in c#
SqlCommand comm = new SqlCommand("UPDATE Contatos Set Telefone=" + " ' " + txtTelefone.Text + " ' " + ",Cidade=" + " ' " + txtCidade.Text + " ' " + ",Email=" + " ' " + txtEmail.Text + " ' " +…
-
3
votes1
answer162
viewsUnity 3D (5) Locking on IOS
I’m developing a game in Unity 3D, but when I run it looks great on PC , Android, browser, Linux, Windows, but when I run on IOS, it keeps crashing. I put only one cube and kept crashing. NOTE: I…
-
3
votes1
answer1040
views -
3
votes1
answer108
viewsProperty of a class that belongs to another context in the Entity Framework
I have a class called Locker that has the following property : public virtual ICollection<LockerReserve> Reserves { get; set; } The problem is that Lockerreserve belongs to a different context…
-
3
votes3
answers2350
viewsAdd multiple items to a list
Is there any way to add several Intin a list<int>all at once? Type List<Int32> ContasNegativas = new List<Int32>(); ContasNegativas.AddRange(30301, 30302, 30303, 30304, 30305,…
-
3
votes1
answer331
viewsRobot to perform Phantomjs-like web procedures
Is there any framework or implementation way to navigate a website programmatically through c code#? I studied the frameworks phantomJS and Selenium, but these have some limitations in relation to…
-
3
votes1
answer310
viewsValidate custom fields of generated classes
To prevent validations made with Data Annotations are lost if the table structure changes, it is necessary to create another class with fields for validation and a class partial, path that this last…
-
3
votes2
answers1086
viewsHow to reference an external library?
I have a project in Asp.Net MVC where I would like to add some new libraries. They are available for download as .dll, but are also available on Manage Nuget Packages. What is the best way to add…
-
3
votes2
answers93
viewsOnly take the last links from a sitemap
using HtmlAgilityPack; using JoeBlogs; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq;…
-
3
votes1
answer98
viewsHow to convert a view to string in the controller?
I’d like to convert that view for string and have the value in string in my controller The problem is that I’d like her to perform a snippet of script that’s in this view The current method I have,…
-
3
votes1
answer2375
viewsDoubt - Visual Studio Export/Import Project
I’m having problems importing projects into VS 2015. The project was done in an earlier version of the IDE and when I import it it doesn’t come with the components correctly added, needing to add…
-
3
votes1
answer613
viewsHow to start on MVC5 ASP.NET?
Hello! About a month ago I started to venture around the world of C# and then I started to study Framework .Net. Soon after I started to study ASP.NET due to the need in my company. Today I use…
-
3
votes1
answer35
viewsError while trying to pass ticket[i] = i;
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Testes { class Program { static void…
-
3
votes2
answers8188
viewsRead specific text inside a . txt in c#
I need to read a text file that contains several lines: 1 C0000000000 132008281 06140214 080515 0000000005990 00000000000000000000000000000000000599000000000000000000000000000 I need to take only…
-
3
votes2
answers10363
viewsWhat is the command to close or quit the game created in Unity?
I’m learning Unity and would like to know what the command to exit the game, ie close the application and also to know this command as I apply to press the back button of mobile Android execute such…
-
3
votes2
answers830
viewsConnection BD C# Sqlite
I have a small application on C# where the database was established in the SQLite, initially to run only locally. But now I need it running on 2 other machines besides the server. I thought about…
-
3
votes1
answer90
viewsProblems with Message Dialog in the Key Down event
I put an event KeyDown in a field TextBox for when the user presses Enter, there must be some action. In this action, I’ve asked for a message to appear Dialog, but the problem is that if the user…
-
3
votes2
answers16833
viewsHow to obtain only the date, without the time, of a Datetime?
Converting a field using ToDateTime it brings the date and time. parcelamento.data_vencimento = Convert.ToDateTime(reader["data_vencimento"]); Is there any direct conversion to bring only the date…
-
3
votes2
answers597
views -
3
votes1
answer77
viewsUse Defaultifempty in a LINQ query with Join
The goal is to join these two list, being that if in the list pr have an item that does not match the list un, the default value will be returned. I know there are other ways, but I would like…
-
3
votes3
answers847
viewsConversion of a variable with replace to decimal
I’m having a little doubt, I pass a value 0,05 decimal for a variable A of the kind string. After this variable receives this value, it does the conversion of , to point ., which remains 0.05 After…
-
3
votes1
answer73
viewsHQL query in C#
Guys, I’m having trouble with HQL and C#. I have the following method: public IList<int> GetListYear(Guid educationalInstitutionId, Guid academicLevelId, Guid? locationId, Guid?…
-
3
votes2
answers102
viewsCan an Exception cause a Sqlconnection to close?
I’m building the treatment of a connection and I came up with this question in mind, yet I couldn’t find a satisfactory answer. So I came here to ask the most experienced programmers. Is there any…
-
3
votes2
answers1532
viewsCapture text between two known characters
I need to pick up any text and find the words (or phrases) that are between two specific characters { and }, in that case. I can do this by capturing the delimiters together, using the expression…
-
3
votes1
answer167
viewsMVC# - Mongodb 2.0 dependency injection
I’m starting a project using MVC 4 with Driver 2.0 of MongoDB. I’m used to using Ninject with EF6 and would like to know if there is such a thing as MongoDBor some example architecture standard for…
c# pattern-design mongodb dependency-injection mongodb-csharpasked 8 years, 8 months ago Jhonathan 1,399 -
3
votes1
answer192
viewsVector start with element greater than 0 (zero)?
Usually a vetor starts from the element 0, and so on until you get to the size of which it was declared or assigned, example: string[] v = {1, 2 , 3}; // equivalente á: v[0] = 1; v[1] = 2; v[2] = 3;…
-
3
votes1
answer379
viewsPagination with generic method
I am trying to create a generic method for paging, I tried to do as the code below, but when using Skip I need to have a orderby and I’m not sure how to do. public IQueryable<TEntity>…
-
3
votes1
answer49
viewsName editing is confirmed in the database but does not happen in the listing
I am editing a column of the database and so far everything goes very well, but when I load the table that contains this column using Include, simply does not update the "Chauffeur", exchange the ID…
c# asp.net-mvc entity-framework linq lambda-expressionsasked 9 years, 3 months ago Luiz Negrini 1,424 -
3
votes4
answers3830
viewsCompare number within a numerical range
I want to create a function that receives a number and check if it is within a range from 1 to 25. What is the best way to do this? private int VerificaIntervalo(int numero) { if (numero > 25) {…
-
3
votes2
answers211
viewsEntity Framework 6 Async and method . Wait()
I have a system that is a Web Api, the control runs a classes like this: public class CrawlBO { public void IniciaProcesso() { ... CarregaConfiguracaoCrawlBO carregaconfiguracaocrawlbo = new…
-
3
votes1
answer277
viewsC# Windows Forms Web Services
I wonder if it is possible to work with web services using the application made in windows Forms. Is it possible ? If so, would you have any reference that might help me solve this ?
-
3
votes1
answer55
viewsUsing Facebook Login on Windows Phone 8.1
I am developing a Windows Phone 8.1 application and it is necessary to use Facebook login. Someone would have an example of how to log in? Thanks in advance.
-
3
votes1
answer88
viewsNegative return from Array.Binarysearch()
I needed to make a comparison of the kind of methods normally created as inList or something like that. When searching the Microsoft documentation, I found the Array.BinarySearch(T[], T). I…
-
3
votes1
answer78
viewsC# - Entityframework | Database Comparison
I started using EF a short time ago, so I don’t know much about it. I would like to know if I have how to make a comparison of my class with the database using EF. Example of comparison: Staff Class…
-
3
votes3
answers884
viewsList of Exceptions
How to implement a class so that I can add an Exception to an Exception list. This class would be used for the case below, for example: In the validation method can return one or more errors, so…
-
3
votes0
answers327
viewsEF mapping of Fluent API associative entity
I would like to know how to do a mapping without using ICollection, or may even be using, but would not want the bank to create a class, just to be able to connect the two classes. class Pessoa {…
-
3
votes1
answer791
viewsCascade Dropdownlist MVC 4
View: <asp:Content ID="Javascript" ContentPlaceHolderID="HeadContent" runat="server"> <script type="text/javascript"> $(document).ready(function () { $("#estados").change(function () {…
-
3
votes1
answer61
viewsGet values from Arraysegment
By creating a ArraySegment, would like to get the new array created, but when using: meuSegmento.Array; the array original is returned and not the created segment. string[] meuArray = {"stack",…
-
3
votes1
answer266
viewsCorrect View Creation on MVC using Ajax
I have a page that performs maintaining a budget. Below I present a briefing of entities public partial class Orcamento { public int IdPedidoCompra { get; set; } public int IdCliente { get; set; }…
-
3
votes2
answers705
viewsError while deleting using Entity Framework 6 and custom repository
I am using the Entity framework to do CRUD in the database, but I have an error trying to delete an item: "The Object cannot be Deleted because it was not found in the Objectstatemanager." I’m using…