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
answers830
viewsHow to allocate program memory and storage before running my application in Wince?
I am reprogramming a C# application to run on Windows CE, but my machine has little memory. Therefore, I need to allocate the appropriate amount of processing memory (program memory) and storage…
-
6
votes1
answer1265
viewsGood practices for Asp.Net MVC 4 - 5
I need to know how to organize my project in the question of CRUD's in case there is more than one Model in my application. For example, I have the student model and the teacher model. I create a…
-
6
votes1
answer682
viewsHow to produce JSON in the format that Highcharts expects?
I have the following code in C#: Dictionary<string, object> dataResult = new Dictionary<string, object>(); dataResult["data"] = new List<object[]>(); dataResult["name"] = i;…
-
6
votes2
answers2883
views -
6
votes2
answers4329
viewsString to Double Asp.NET C#
I need to convert a String value (returned by the database) to Double but when I do, it simply modifies the value. Example: the database returns 22.5, when I convert to Double at 225.0. String…
-
6
votes3
answers1123
viewsError in C# function to increment variable
Guys, I’m new and I have some "basic questions". I’m making a score, because there are many players I want to create the function to decrease/ increment. Incremental function public void…
c#asked 10 years, 6 months ago AndersonBP 143 -
6
votes2
answers1506
viewsCompare date time with a timespan
On Asp mvc 4, I’m doing a query where I find the data where the hours are lower or equal than those entered by the user. That is, I have a dateTime and check with the user input variable (a…
-
6
votes2
answers26381
viewsProblem connecting to SQL Server 2012 database on IIS
I cannot run my system queries on IIS, when running in Visual Studio I can get the result easily. The mistake I get when I try to do something is this::…
-
6
votes2
answers387
viewsHow to create a View for this Template case?
I’ve been trying to apply the solution to this question (How to pass checkbox list to Actionresult) in a problem I’m having but I’m not getting a positive result. I’m getting an array with several…
-
6
votes1
answer237
viewsHow to convert a value in UNIX type Timestamp to Datetime?
How to convert a value to type UNIX timestamp (seconds since 1970), example 1396148400, in a DateTime?
-
6
votes2
answers2788
viewsHow to create a report with Crystal Reports parameters?
How to create a report with parameters in Crystal Reports? Create the report for me has no problems, but now I need to filter it according to some parameters of the system table. Can someone help me…
-
6
votes3
answers5346
viewsClone class objects using Icloneable
I’m trying to use the Interface Icloneable to copy an object, but I’m having a problem when it has a class property because the Icloneable does not create a new memory address for these objects, but…
-
6
votes1
answer2229
viewsHow to add a control dynamically in C#?
How to add a control to a page ASP.NET dynamically using C#?
-
6
votes2
answers330
viewsImplement composite key C#
I’m performing some tests and managed to implement using this form: public class Residencia { public object Id { get { return String.Concat(Cidade, Estado); } set { } } private string Cidade;…
-
6
votes3
answers285
views"Gambiarra" in C# with XML, I would like suggestions for improvement
I have this code without the "gambiarra", which returns the list with the repeated values: var s = (from p in xmlDoc.Descendants("pais") let Nomepais = p.Element("nome-pais").Value let nomeconsulado…
-
6
votes1
answer776
viewsReplicate/Copy elements from multiple tables
I have the following situation: The user has defined an establishment, where he has filled in data in two tables, and intends to replicate/copy all the same data, changing only the id of the…
-
6
votes1
answer363
viewsDetect Caps Lock C#
I made an application to detect the state of caps lock in C#, but I found a problem, when the application loses focus events can no longer be triggered causing notifications to no longer be…
-
6
votes4
answers6284
viewsHow does an empty constructor work?
Definition: Creating an empty constructor attributes if not set will be set to the default value of guy, example: int default value is zero. Context: Use a structure that returns entities from the…
-
6
votes2
answers874
viewsHide different options (actions) for different user profiles
I am in a project where I have 3 different levels of profiles: Administrator, Professor and Coordinator. I already have the login module, registration and such. What happens is that I wanted for…
c# asp.net-mvc asp.net-mvc-5 razor visual-studio-2013asked 10 years, 4 months ago Érik Thiago 2,338 -
6
votes2
answers895
viewsRemove "/" from a Datetime.Toshortdatestring();
I am implementing a program using C# with . net 3.5 I have the following code: StringBuilder sb = new StringBuilder(); sb.Append(caminhoSalvarCobranca); sb.Append(@"\Boleto ");…
-
6
votes1
answer5290
viewsMethod that returns a class
I am trying to create a method that takes a string and returns an instance of the class with the name passed, example: "Calculator", will return me an instance of the class "Calculator" (If it…
-
6
votes1
answer13850
viewsJoin with three or more lambda tables
I made this expression using Lambda and 2 tables. var resultado = db.T_TarefaParceiro.Join( db.T_OsParceiro, t1 => t1.IDTarefaParceiro, t2 => t2.IDTarefaParceiro, (t1, t2) => new { t1, t2…
-
6
votes1
answer2820
viewsCompares Datetime field in a lambda only part Date
In this lambda, result will almost always be null, because I gave a Getdate() straight at the bank and when this happens, I record Date and Time. How do I make this lambda pass only Data and compare…
-
6
votes4
answers2718
viewsGenerate sequential Ids without losing the sequence
For Identity do not want, because it breaks the sequence if something happens. Max() + 1, I find it very vulnerable and slow when you have a lot of records. So I ask you, is there a way that someone…
-
6
votes2
answers1269
viewsWhich Pattern is used to validate business rule?
I use Repository Patterns for searches,save and delete I wonder where is the best validation of my business... Ex: I need to check if the item is in a contrato of a prestador, and bill him with the…
-
6
votes2
answers2534
viewsRendering Partials in ASP.NET MVC
I’m having a problem in my application where I wanted to use partial to render one page inside another. That is, one controller within another. Only, what happens is the partial does not render at…
-
6
votes3
answers1183
viewsHow to Dropdown ASP NET MVC
I have a DTO class [Serializable] public class PerfilDTO { public int Codigo { get; set; } public string Descricao { get; set; } public SituacaoEnum Situacao { get; set; } public…
-
6
votes2
answers1395
viewsDoubt in inheritance exercise in C#
I’m trying to solve an inheritance exercise and I found a question that I saw that you have a chance to show up in other places and so I thought I should ask here. The exercise asked to first create…
-
6
votes1
answer913
viewsCorrect Statement Classes Model MVC Ninject
I started using OO a short time and in all projects I see on the net, I see the following way of statement. public class Trabalhador { public int Id { get; set; } public string Nome { get; set; }…
-
6
votes3
answers1504
viewsCopy file with progress
How I use the C function# File.Copy(string path); to copy a file by incrementing a value in a Progressbar?
-
6
votes3
answers1328
viewsReturns Json of object in C# with Entity Framework
I’m having a problem returning a Json using Entity Framework. The code I’m using is: [AcceptVerbs(HttpVerbs.Get)] public JsonResult Item(int agendaHorarioID) { using (var db = new ERPContext()) {…
-
6
votes4
answers4082
viewsChange page without changing user URL
How to switch pages internally without changing the user URL? Without using frames. Example: The user has entered my site: http://exemplo.com and clicked on the menu and went to the page "Contact".…
-
6
votes4
answers3435
views -
6
votes0
answers1367
viewsReportviewer Generic error GDI+
In Reportviewer, some generated requests are generating an exception, and when this happens, I can’t even export to PDF, but to DOC it works. Does anyone know what’s going on? I use C# with VS2010…
-
6
votes1
answer2258
viewsHow to fix the unrecognized Attribute 'name' error in Webconfig?
I am developing a web project in VS 2012, this application connects with a Mysql database developed in Mysqlworkbench 60 CE with Mysql server 5.6, I have referenced in the project the…
-
6
votes4
answers1593
viewsChanging connectionStrings from the app.config physically in Runtime
In my app.config I have the following lines of code: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> </configSections> <connectionStrings>…
-
6
votes4
answers438
views"Clean" way to modify the "Visible" attribute of a Picturebox
I have 5 background images for my application and that will be visible to the user’s taste. What is the simplest way (clean code) to get the user to choose? private void…
-
6
votes1
answer7747
viewsHow to resolve the medium trust issue in Asp.net
I’m developing a website on Asp.Net MVC5. When posting the site on Locaweb and trying to log in with my user I received the message: Attempt by security transparent method…
c# asp.net-mvc asp.net asp.net-mvc-5 asp.net-identityasked 10 years, 4 months ago Renatto Machado 715 -
6
votes1
answer156
viewsError while using Random
I set a random number to fill a fictitious table and did so: foreach (var usuario in LstUsuarios) { htmlUsuarios.AppendLine("<tr>"); htmlUsuarios.AppendLine("<td>" + usuario.Nome +…
-
6
votes2
answers605
viewsWhat better way to organize and work with ASP.NET MVC routes?
What better way to organize and work with ASP.NET MVC routes? While we have 1, 2 routes, it’s quiet, but when do we have 500 ? 600 ? In an enterprise application there are many routes, which is the…
-
6
votes1
answer271
viewsIntegration with GIT
I wonder if Git provides an integration API, like I’m developing a C# application and would like to know if there’s any way to get the files from the latter Commit. I took a look at the GIT website,…
-
6
votes2
answers83
viewsResponsibilities of the View
Throughout the internet, I find posts warning about the responsibility of View that should only take care of its name and display the content. Although MVC is based on exactly the distribution of…
-
6
votes3
answers3565
viewsUse ajax with Actionlink
I want to change the ActionLink and the URL to work with Ajax, but I don’t know how to do it. Follow my code with ActionLink and URL. <ul class="nav" id="side-menu"> <li> <a…
-
6
votes3
answers905
viewsProblems with Double formatting
I have a method that gets values like string and performs the conversion to other types, my problem is that when converting an information to double It changes its precise value so that it doesn’t…
-
6
votes2
answers429
viewsHow to filter a list asynchronously using LINQ?
Example of code without the use of async: var products = db.Products.Where(_ => _.UserId == currentUserId); How do I make this asynchronous query taking into account that the Where of Linq does…
-
6
votes1
answer475
viewsWhat can cause the RU’s performance to fall in this scenario?
I’ve been making a data import for a project on ASP.NET MVC 5 with EF 6.1 and SQL Server 2008 where the import data source was a file txt. The record lines of the file were not very large but…
-
6
votes2
answers5551
viewsGenerate random CPF in C#
I need a generic class to generate valid CPF to send value to fields with the webdriver Selenium. Someone has the code? Thank you.
-
6
votes1
answer142
viewsConversion error in a query
I made this consultation and in Where is giving this error: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to…
-
6
votes1
answer5794
viewsHow to use MVC 4 session with C#?
My scenario is as follows. I have an MVC 4 application. In my controller I check the logged in user and password. (I think) I put the user data in a session after the data is checked and correct. My…
-
6
votes3
answers42780
viewsHow to change date format in bootstrap from mm/dd/yyyy to dd/mm/yyyy
That’s the mistake you’re making: Uncaught Typeerror: Cannot set Property 'en-BR' of Undefined Insert some links to format the date, according to what I took on the net and even then the date is…