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
-
5
votes1
answer175
viewsHow competition works on a single thread with C#
This is a purely didactic question. I’m trying to understand how the competition model works in C#, specifically by using the async modifier. I come from Javascript, and I understand that in the JS…
-
5
votes1
answer247
viewsAsync/await generates a new thread?
When reading about async/await methods, it is said that using these keywords alone will not cause your method to run in a new thread. However, I get the output below by running my code. A thread was…
-
5
votes1
answer91
viewsWhat kind of data do you use to store the date of death in a register (Datetime or string)?
I have a record of people where I need to store birth dates (DateBirth) and death (DateDeath). Knowing that the guy DateTime in C# cannot be empty and its default initial value is 01/01/0001…
-
4
votes2
answers670
viewsWhat is the equivalent of Usercontrol in ASP.NET MVC?
In Web Forms we have UserControl. These controls have a code-Behind and a layout. They can be used in different projects/solutions without depending on other things. I want to create a control that…
-
4
votes3
answers249
viewsHow can I manipulate a PSD file to get the position of the layers?
I am working on a project where we have a file . psd (Photoshop) called "sprites" that contains all the icons of the site. I would like to get the positions of each layer to automatically generate a…
-
4
votes4
answers491
viewsHow to get the name of the property to which a lambda expression refers?
I have a lambda expression being translated into an expression tree (Expression Tree) as follows: Expression<Func<object>> expr = () => x.NomeDaPropriedade; How do I get the name of…
-
4
votes2
answers747
viewsEF6 Code First Relation between entities
I am trying to create a Condominium data model in ASP.NET with SQL Server. I stumbled on the creation of the interface proprietario(1) with the fracao(many). The error returned is: The INSERT…
-
4
votes3
answers5030
viewsKeep zero after comma using the float type?
I have a database where product values are stored. When there is occurrence of numbers with zero after commas they come without zero. I did a test and with decimal it worked, but my application uses…
-
4
votes2
answers442
viewsCode First with Complex Types, when making Scaffolding the properties of Complex Types are not found in the views
I’m following Sergey Barskiy’s presentation on http://www.youtube.com/watch?v=l3WzYZsN0gU, where it demonstrates the Entity Framework approach with Code First. I loved it, but I had a problem. In…
c# asp.net-mvc entity-framework code-firstasked 10 years, 8 months ago Guilherme de Jesus Santos 6,566 -
4
votes2
answers599
viewsHow to update backgroundWorker.Reportprogress() through a class in another project?
I read a text file that contains data from another database, upload that data line by line to a class, edit the required fields and then save it to the new database. This insertion processing…
-
4
votes1
answer308
viewsAutomatic reading routine between 2 C#databases
I need to create a C# routine that reads 2 databases and feeds the reading data into another database. The development part of the system itself I can do without problems, but I don’t know what kind…
-
4
votes3
answers1154
viewsHow to verify if there is a specific value (string) in a list in C#?
I am trying to mount a select Multiple input and leave marked the options that are already present in a certain list. I’m a beginner in C# so the logic of what I need would be more or less this:…
-
4
votes3
answers629
viewsLog into page using the bank ID in ASP.NET
I need to make a page that can be accessed in the following format: www.exemplo.com/id/123qwe That one 123qwe is the ID of a database line, where I’ll get all the data to fill out the page. So far…
-
4
votes2
answers144
viewsCompare Dayofweek in an ASP MVC query
I’m trying to make a query where I check if the day week is chosen to create a list of data that loads in a Viewmodel. Query: var plan = db.Servicos.Where(s => (TecnicoResp.HasValue ?…
-
4
votes1
answer264
viewsSpecific application of attribute [Childactiononly]
I saw from the ASP.NET MVC documentation that the use of the attribute [ChildActionOnly] prevents the method from being called directly via GET, only through a specific view. Frankly, I don’t…
-
4
votes2
answers1930
viewsC# - Path to execution
I am making a Auncher, however I would like to leave the files with a "fixed" path, the Auncher is in the same folder of the file to be started, but I do not know how I could create a "middle way",…
-
4
votes2
answers4221
viewsHow to use HTML Agility pack?
How to Use HTML Agility Pack my project in Visual Studio in C#, as I have a table extracted by an object webbrowsers, the more I go splits in it it stands like an array of almost 700 indexes, I…
-
4
votes2
answers1874
viewsHow to put buttons/titles with different design/style in C#?
In C# is there any way to put for example buttons with a different design, or the title with a different style? I want to put my program more "Fancy".
-
4
votes3
answers2237
viewsConstruct string with special characters
I am building PDF’s, and I need to print a string with special characters. I am constructing the string as follows (using iTextSharp): PdfPCell teste = new PdfPCell(new Phrase("<O meu texto>…
-
4
votes2
answers231
viewsRemoving comments in the HTML sent by the server
We all know the good old HTML comments: <!-- Oi, eu sou o Goku! --> The point is: there is some way to delete HTML comments that the server sends to the client? I think such configuration is…
-
4
votes1
answer1871
viewsI am unable to make the value of a property selected using the Razor Helper Dropdownlistfor
Dear Ones, in my ASP.NET MVC 5 application I am using . Net 4.5 I am unable to make the option to be selected for a certain property. Example of my class: public class Funcionario {…
-
4
votes1
answer4398
viewsHow to configure Context not to put table name in plural?
I am in an ASP.net MVC 5 application, configuring a class DbContext. When the EF generates the database, the tables referring to the application objects are getting names in the plural. For example:…
-
4
votes2
answers241
viewsPopular programmatically x data manually
You can popular one-component data on .NET using Visual Studio interface (Select Datasource...). From the point of view of popular performance data via code is faster than manualmentr?…
-
4
votes1
answer934
viewsError: Registering ? instead of special character only using browser
I am having a problem at the time of saving the data in my ORACLE database. When using my application to fill in the fields and register a string, the special characters as accents for example are…
-
4
votes2
answers2690
viewsEF 6, Fluent Api mapping in inheritance classes
I am training in class mapping for the Entity Framework using the Fluent API and I have some questions. The first is as follows: Map a Foreign key with attributes would be like this: public int…
-
4
votes1
answer1875
viewsConvert encoding CP850 to UTF8
I have a BD Paradox that returns me the following string after a query in a table of the sector that a certain worker is: Manutenþòo Elútrica. Actually it should be Electrical Maintenance. I need to…
-
4
votes1
answer577
viewsRedirect to external URL with basic Authentication in MVC
I am developing a C# MVC3 portal and in a given operation I need to open another portal in a separate window. To open the page of this new portal I need to send some credentials, since this is…
-
4
votes1
answer1976
viewsCalling an executable other than Process in c#
Is there any way to call an executable other than by process? I need something that does not use the code below to call an executable because when I finish a process of an application that is not…
-
4
votes1
answer772
viewsHow to always leave a form behind?
I’m trying to always leave a form underneath the other forms, no matter if the user clicks on it, it should always be below, but usable, something similar to the desktop, and that’s the problem, I’m…
-
4
votes1
answer1406
viewsC# Receiving Serialized Objects on a Webmethod
Good afternoon, I am passing a list of JS objects to C#, to a Webmethod, as function parameter, what kind of parameters this should be? I created a class to receive the data: public class…
-
4
votes1
answer966
viewsHow to implement the six degree separation theory algorithm?
What is? Theory that in the world it takes no more than six bonds of friendship for any two people to be connected. Question: I’ve been trying for some time to implement this algorithm, but I can’t…
-
4
votes2
answers2456
viewsEnd a C# process with WPF
I have a solution that has two projects. a main project and another that serves as Updater. To perform the upgrade, within the main project, I call a console application as follows. private void…
-
4
votes1
answer491
viewsHow to create a Managed Thread in C++ similar to the example in C#
In C# I use the following code to create Managed Thread: Thread thread = new Thread(new ThreadStart(minhaFuncao)); In C++ i made: using namespace System::Threading; . . Thread^ thread = gcnew…
-
4
votes2
answers1311
viewsHow to get position of a sub-list within another list?
I have a list of bytes and I need to check if it contains a sub-list of bytes in a specific order. How can I do this check by getting the position of the sub-list in a simple way, using the…
-
4
votes1
answer551
viewsHow to smooth the transition between pages on windows phone?
How I improve the transition page from page on Windows Phone? Because every time I change pages, it changes like "out of nowhere", it doesn’t appear smooth, like a normal transition. Has effects…
-
4
votes3
answers1073
viewsC# update XML based on another XML
Today I have the following XML structure: <ROOT> <TES IDTES="4780" IDPES="17522" /> <TES IDTES="6934" IDPES="12343" /> <TES IDTES="4781" IDPES="17523" /> <TES IDTES="6935"…
-
4
votes1
answer446
viewsHow to internationalize Enum values?
I have the following code in Model: public enum Lista { [Display(Name = "Lista_regular", ResourceType = typeof(Mensagem))] Regular = 0, [Display(Name = "Lista_irregular", ResourceType =…
-
4
votes1
answer350
viewsDefault browser autocomplete does not work in my Webforms application
I’m using the Google Chorme and he’s got the option autocomplete enabled, so much so that I can store a login to the Facebook. However, in my application ASP.NET Webforms, on the screen of login me…
-
4
votes1
answer952
viewsAdding Referenced DLL to a C#Executable
I developed a console application in C# that makes use of a referenced dll. After batch build and generating the application executable, I tried to run it on a computer that did not have this dll,…
-
4
votes1
answer178
viewsHow do I make an event when I click an Item?
I wanted to know if there is a way, when clicking on an item, to perform an event/function, knowing that each item has its function. I’m using Longlistselector Código XAML <phone:LongListSelector…
-
4
votes1
answer3291
viewsHow to pass parameter from one Controller to another in Asp.Net
Hello, I have an object that I need to pass by parameter to another Controller through the RedirectToAction, used the TempData but after any page change it loses the reference, know of any solution…
-
4
votes3
answers7464
viewsRound numbers in C# to decimal 0 or 5
I need to round up numbers in such a way that they only have a decimal value of 0 or 5. For example 1 -> 1 1.1 -> 1.5 1.4 -> 1.5 1.5 -> 1.5 1.6 -> 2 2 -> 2 Someone knows a simple…
-
4
votes1
answer90
viewsXML duplicating the reading of the results
I have a XML: <paises> <pais> <nome-pais>África do Sul</nome-pais> <consulados> <consulado> <nome-consulado>Consulado da República da África do…
-
4
votes2
answers5206
viewsFile supposedly being used cannot be deleted
I have a software that records error logs of itself inside a "logs" folder. Each log file is created with the current day date, so it is unique to the current day. Example: 30-04-2014.log. I use…
-
4
votes1
answer145
viewsHow to change the type of the persisted class in a legacy model using the Entityframework
I have the following class scheme with inheritance, as an example: public class Veiculo { public int Id { set; get; } public string Descricao { set; get; } } public class Moto : Veiculo { } public…
-
4
votes4
answers1399
viewsDatabases for different customers
I am learning MVC 4 and would like to know if there is a way with only 1 model access different databases? For example, I have an online system and for each customer I have a separate bank. What…
-
4
votes1
answer925
viewsPVC badge printing with thermal printer
I’m with a thermal printer to do some tests of printing badges with cards pvc. At first I set up a model badge on Reportviewer and I’m generating it in pdf. And apparently she’s losing a lot of…
-
4
votes1
answer185
viewsWhy doesn’t the "Landscape" position resize the Longlistselector?
Why when I put the phone in the Landscape position, the LongListSelectordoes not resize? Follow the image: Follows my XAML <Grid x:Name="ContentPanel" Grid.Row="1" HorizontalAlignment="Center"…
-
4
votes1
answer2652
viewsWeb Api Client in Windows Forms
I am making a client using Web Api. My site has the server function of the Web Api. I found this reference from Microsoft…
-
4
votes1
answer280
viewsC# Union/Order by with LINQ and Performance
Imagine the following situation there are 3 classes class A, class B, class C, class A has many classes B and many classes C. class B has many classes C. clsse C has a data datetime field. public…