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
-
6
votes2
answers5645
viewsRemove special characters and spaces from a string?
I have a problem, in an app I’m picking up the contacts from the phone book, but I want to do a treatment on the numbers of the contacts that can come like this: (99) 9999-9999 9999-9999 9999 9999…
-
6
votes1
answer640
viewsWhat is the difference between a DLL produced with C++ and a C#
After some time searching, I did not find any results for this issue, the topics already existing in MSDN also returned nothing in relation to support of the 2 in Windows. In summary, the question…
-
6
votes1
answer71
viewsWhy can’t I display Messageboxbuttons if it’s not a string?
'Cause I’m having trouble showing off MessageBoxButtons if it is not a string? static void Main() { string texto = "Minha primeira MessageBox"; MessageBoxButtons botao = MessageBoxButtons.OKCancel;…
-
6
votes1
answer671
viewsError after performing an action redirect to a page
I believe I am going wrong the code below, it should after saving the Client and redirect to Client/Index page, but after saving is on the same page, using Debug it passes in Client/Index(Action and…
-
6
votes1
answer660
viewsHow to send Winform images to a Webapi service c# on both sides
I have two apps, a local running Winform and a remote hosted Webapi. Already send data to the served from Winform, the code is like this: JavaScriptSerializer json_serializer = new…
-
6
votes1
answer522
viewsEntityframework 6 + Lazyloadingenabled + using()
I need a help. My problem is this: I cannot return my object items. Follow my code for analysis. Client class public partial class Cliente { public Cliente() { this.ClienteEndereco = new…
c# asp.net-mvc entity-framework-6 lazy-loading repositoryasked 9 years, 4 months ago Henrique Abreu 379 -
6
votes1
answer308
viewsWhat is the use of indexers?
I was watching and the Csharp has indexes. Second definition on the website microsoft: Indexers allow instances of a class or structure are indexed only as vectors. Examples: internal class…
-
6
votes1
answer694
viewsHow to pick up attribute dynamically
How I would make the following PHP code in C#? class teste{ public $x = 10; public $y = 10; } $n = new teste(); $a = "y"; print_r($n->{$a}); Note that dynamism is in the variable $a, in which if…
-
6
votes2
answers1387
viewsSimplify LINQ query with Contains
I have two questions regarding the LINQ consultations below: { //lista de itens do orçamento var ids = itensOrcamento.Select(p => p.Id); //Produtos - todos produtos cadastrados var produtos =…
-
6
votes1
answer728
viewsAjax in different project
I have a project in Asp.Net MVC with the following method: public ActionResult ObterCursos() { List<curso> cursos = new List<curso>(); curso curso_ = new curso(); curso_.Nome =…
-
6
votes3
answers4902
viewsHow to load a dropdown with a selected value
I have a method to make changes in some data. Among these data, I have a dropdownlist which contains course periods. When I select to change, I need the dropdown comes with the option checked, as it…
-
6
votes1
answer2687
viewsString signature in Base64
In my project, I have a rule that I need to sign the string of a XML that I have you on Base64 with the user’s CPF... I’ve been doing some research, but I couldn’t quite understand how this…
-
6
votes1
answer734
viewsError: "You must add a Reference to Assembly 'System.Runtime.Serialization'"
I’m making this mistake: The type 'System.Runtime.Serialization.Iextensibledataobject' is defined in an Assembly that is not referenced. You must Adda Reference to Assembly…
c#asked 8 years, 7 months ago user39571 -
6
votes1
answer297
views -
6
votes3
answers1233
viewsHow to login to desktop application via web application?
I have a web application developed with ASP.NET MVC and log in by storing the data in Session. I have another application, however desktop, that performs some tasks that cannot be done on the web,…
-
6
votes1
answer781
viewsConnection pool with ADO.NET and Sqlconnection Dispose, what is correct to do?
I asked a question yesterday about What is the difference between Idisposable implementations? I was implementing a class to help obtain instances of SqlConnection, SqlCommand, SqlDataReader methods…
-
6
votes1
answer493
viewsHow to recover the page HTML generated with Angularjs via C# ?
How to recover HTML code from a page that uses Angularjs to process some information and generate a graph? I was able to easily recover the HTML code using Webrequest as demonstrated in the example…
-
6
votes2
answers436
viewsDelegates and methods
When to use delegates? Being that a delegate points to a method, it is not the same thing as creating a normal method? What’s the difference and when to use and why to use? It’s better? Is worse?…
-
6
votes1
answer947
views -
6
votes2
answers338
viewsComments on regular expressions?
REGEX is a very complicated language and not easy to read, but is there any way to describe what that little letter does? Example: Nessa regex: \{.*?[^\}]+\} will capture everything you have in a…
-
6
votes2
answers9189
viewsReturn today’s date in C# in specific format
My way out has to be "2015-02-01" I tried to get DateTime.Now.ToString("yyyy-m-d"), but she doesn’t 0 between days and months.
-
6
votes1
answer303
viewsCode block freezing and does not release Exception
I am using the Twain library for scanner,and the application lists some devices that when selecting does not work,so I debugged and saw that it does not launch the Exception I treated, and yes it…
-
6
votes3
answers101
viewsIs there any justification for this change? Change in variable pattern
A coworker read on a forum that using shorts, int and long was the right and best way for the system’s performance, so it began to change on all screens and classes it worked on. I searched and saw…
-
6
votes2
answers901
viewsExtract file . ZIP with accent on name
I’m using the lib System.IO.Compression.ZipFile to unzip files .zip and came across a big problem while trying to extract files that have accents in the name. If I try to extract with encoding…
-
6
votes2
answers897
viewsHow to filter items that do not contain a word in a list?
I have a: List<Grupos> lista = new List<Grupos>(); And I have this code var txtFiltro = "noivas,unhas"; var palavrasFiltro = txtFiltro.ToLower().Split(','); matches = lista.Where(x =>…
-
6
votes1
answer2951
viewsLEFT JOIN using Linq
I have the following tables: Responsavel | Filho Id Nome | Id Nome ResponsavelId 1 Ana | 1 Aninha 1 2 Maria | 2 Ana Júlia 1 3 Pedro | 3 Mariazinha 2 I’d like to make a SELECT with INNER JOIN where…
-
6
votes2
answers519
viewsWhat is the best place to store the connection string?
There are some possible places to store the string connecting. Leave tied inside the code, app.config, Windows registry and configuration file. What is the best place to store string connection?…
-
6
votes3
answers413
viewsHow to replace dynamic chunk {{chunk}} of a string in C#?
I get a string dynamically generated example: "Dynamic text {{parametro1}} plus a piece of text {{parametro2}}". I have in C# a code similar to this: where the name is the same that is between keys…
-
6
votes2
answers312
viewsWhere to call Savechanges() when you have multiple repositories?
I am developing an application with Entity Framework, with several repositories. Each repository encapsulates SaveChanges() dbcontext. When a business layer operation uses multiple repositories, and…
-
6
votes2
answers2547
viewsHow to get out of a cycle in C#?
I need to get out of the foreach when the value is equal to 1 foreach (DataGridViewRow dr in dgvValetes) if(dr.Cells["valor"].toString()=="1") //Sair aqui I don’t know how to do...…
-
6
votes1
answer117
viewsProblem with the datakeynames property of the listview component
I get the following error when running the application: Message=Databinding: 'Gesthos.Models.Documents.Fluxoapprovacaodocumento' does not contain a Property with the name 'Sector.Code'. Error…
-
6
votes1
answer7802
viewsVoice recognition in Pt-BR
How do I use Speech Recognition when my OS(Windows 8 x64) is in En-BR? I want to use commands in English. I’m using the following code: private void Form1_Load(object sender, EventArgs e) {…
-
6
votes2
answers878
viewsMVC Ioc Builder without parameters
Hello. My application is triggering an error while trying to create a new item. I’m getting this error message: No constructor without parameters has been set for this object. But my controller…
-
6
votes1
answer96
viewsKeep a certain frame within an android app
I’m trying to manipulate the frame rate (frame rate) within a Unity scene, when I run it on the Unity platform, it works with the particular frame value I sent. However, when I pass it to my cell…
-
6
votes1
answer310
viewsSearch list elements with partial strings
I have a List<string> who receives the phone number of all the contacts on the phone, until there is no problem, but I want to perform some operations with the elements of that list, but I am…
-
6
votes2
answers840
views -
6
votes1
answer1270
viewsCalculate cubic root
I’m having trouble creating the following Root and LN buttons. I have buttons that should be very similar as for example the normal square root and the log. I tried to create the following for the…
-
6
votes1
answer742
viewsSelect Gridview line with checkbox
function Selecionar(elemento,cordefundo) { var Inputs = elemento.getElementsByTagName("input"); var cor = elemento.style.backgroundColor; //manter a cor default do elemento for(var i = 0; i <…
-
6
votes3
answers459
viewsDoes C# have a class for handling properties files?
In C# has some class for handling files properties? In Java I use the class Properties, I was wondering if you have a C equivalent#?…
-
6
votes2
answers1515
viewsData Displayfor display formatting
I have a field in the database, Date Time, and wanted to display on screen to the user, but in separate fields, being Date and Time. First displays the Date @Html.DisplayFor(modelItem =>…
-
6
votes3
answers1227
viewsIs there a Data Annotation that prevents data duplication in the Database?
How do I prevent data from being duplicated in the database using Data Annotation or via another validation?
-
6
votes1
answer187
viewsDownload FTP using c#
I am trying to download an FTP server. The problem is this: I need a way to partition the file I am downloading. So that it is downloaded part by part and not complete at once. Doing asynchronously…
-
6
votes2
answers141
views -
6
votes1
answer201
viewsDoes the keyword "async" really make the asynchronous method?
I was seeing a video (at 31:11 minutes) and there says that async does not make the method really asynchronous, it is more a "hint". As it was in English and I am not totally advanced, it was half…
-
6
votes1
answer523
viewsI’m not getting a Oracle file with Code First
Here’s what I’m doing: Folder Model dou Add > New Item follows pictures Then select ADO.Net Entity, give a name and ADD I select Code First and give Next Well in this step, I select , and look at…
-
6
votes3
answers269
viewsI need to sort a list in order that seems unusual
I have a query and want to sort this query by the attribute code. I did it as follows: consulta.OrderBy(c => c.Codigo); Result obtained: 1.01 1.A 14.04 14.11 22.01 3.04 30.01 4.01 40.02 Expected…
-
6
votes1
answer843
viewsDataannotations for checking between Start Time and End Time
I have two fields of type [Datatype(Datatype.Time)], being Start Date and End Date, and I cannot let the user enter the End Date less than the Start Date for the purpose of calculating hours worked.…
-
6
votes2
answers191
viewsDoes the List<T> Method. Foreach exist?
I’m trying to implement the example of this page, but VS2015 (.NET 4.5) says the method ForEach() there is no class Program { static void Main() { List<String> names = new…
-
6
votes1
answer1213
viewsInstall app made in Visual Studio on client machine
I created my first Windows Forms application and will install it on the client’s machine. How should I proceed? Just the .exe and the database?
-
6
votes3
answers647
viewsAuthorization of users to actions using the Authorize attribute
I put the [Authorize] in my controllers and I inserted this code: <authentication mode="Forms"> <forms loginUrl="/Login/Login" /> </authentication>` For whenever the 401 code…