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
answer1029
viewsSave automatically generated excel in ASP MVC application
I am generating Excel files in my application using Epplus. Now there is a need to automatically store these files in a folder, regardless of whether the user downloads them or not, in order to make…
-
5
votes1
answer303
viewsMultiple types of authentication
In my system I need to have two types of authentication one for common user who will register and etc.. and another for the administrator my question is how I differentiate the two authentication…
-
5
votes3
answers2113
viewsApplication that does not need to load full page
How can I create an MVC C# with Razor, where I have a Layout and then just update the central content and not the page as a whole. I read some places to use AJAX another to use PartialView. But what…
-
5
votes1
answer543
viewsWhen a DLL goes up in the "bin" folder all users lose session
Every time I upload a DLL from my site, I take down all users who need to session to remain logged in the administration. I was using the build that turns everything into . dll and . Compiled but…
-
5
votes2
answers6164
viewsGrab information from object Sender
How does the search for information through the Nder object work and in what situations can I use it, with what types of events? This is to avoid event redundancy. Where can I explore these…
-
5
votes1
answer122
viewsIs there any advantage in avoiding type specification redundancy?
Given the following code: public override Entidades.ControleAcesso.Perfil PreencherEntidade(IDataReader dr) { return new Entidades.ControleAcesso.Perfil() { Codigo =…
c#asked 10 years, 4 months ago okevinlira 927 -
5
votes2
answers188
viewsC# Difference between Beginaccept and Acceptasync
What is the difference between the two asynchronous forms? Which has better performance handling sockets and handling thousands of connection simultaneously? Example for Beginxxx:…
-
5
votes2
answers1137
viewsStandards for user authorization/permission
There are other standards for user authorization/permission other than the Role-based access control standard implemented by Microsoft for technologies. NET?
-
5
votes1
answer1220
viewsSend "@Html.Beginform" to another area controller. Asp.Net
I own a controller in a Area calling for "LoginProfessional", with the actions Index, Logon, Logoff. I make a RenderPage calling for the Index in Area root of the project, but when I click on the…
-
5
votes2
answers221
viewsWhat is the reason for using Dbmigration in Codefirst?
What is the goal of using Dbmigration when developing a project using Codefirst? Using it is a good practice, or is something that does not cause major impacts on the implementation and/or…
-
5
votes4
answers661
viewsHow do I execute a method at the end of each method in my class C#
He had a father class and another daughter and would like to perform a certain method, as an event, always at the end of each call of the method of the daughter classes. How can I do?
-
5
votes2
answers281
viewsYield Return inside a using
Consider the following situation: public class MeuRecursoBemCaro : IDisposable { public T FazerOperacaoBemCara(T item) { //Do operação } public void Dispose() { //Dispose logic } } public…
-
5
votes4
answers8104
viewsHow do I make a connected Dropdownlist with a model property?
I have my class: public class Topico { public int Id { get; set; } public string Nome { get; set; } public string Observacao { get; set; } } and my Subtopic class public class SubTopico { public int…
-
5
votes3
answers51028
viewsRegex - Special Character Removal C#
Regex.Replace. is a great solution to remove accentuation. Now I just can’t do the removal of a character type, I have a string that receives the text "1° General Place", string has the character…
-
5
votes1
answer704
viewsDatetime field view in View without part of Hours
With the code below I am recovering the Datetime with time past the date, what I would not like. cursos.Data = DateTime.Parse(collection["Data"]); I tried to format using substring inside…
-
5
votes4
answers1684
viewsDynamically check which attributes of a Model have been changed?
I am developing an ASP.NET MVC 4 application and need to save the log of each change made in a Model object. Is there any native method or implementation already known to do this? Example: public…
-
5
votes3
answers1128
viewsEntity Framework - Update nested lists
I have the following schema in my Mysql BD: Models have a list of standard_images and each standard_images has a list of standard_regions. I must use Entity Framework 5.0.0. I have a model with 3…
-
5
votes1
answer68
viewsIsolated Storage or SQL Server Compact
I’m making for Windows Phone 8.1 something similar to a dictionary where there will be a lot of text with sort, search, sort by name. Bearing in mind that there will be this large amount of…
-
5
votes1
answer128
viewsRead tokens in infinite loop
I have a code that reads tokens a text. I’m using Visual Studio 2013 in an extensibility project. When reading the text through scanner and collect the tokens, the program enters an infinite loop:…
-
5
votes1
answer1794
viewsOnly get user name in AD
With this code, I bring everything, Dominio/User. ViewBag.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name; I would like to bring only the user name. I can take all this, and take…
-
5
votes2
answers2331
viewsHow to use the nhibernate Fluent appropriately?
A problem I have encountered due to the inexperience with this type of tool is HOW to use Lazy load without interfering with the software architecture. I use the following architecture: HMI (Human…
-
5
votes2
answers1071
viewsHow to know the name of the Actionresult that called the view?
I wonder if it’s possible to get the name of ActionResult who called the View. I know that normally View has the same name as ActionResult, but in my case, I have a single view for two ActionResult…
-
5
votes1
answer486
viewsHow to extract the numerical part of a monetary value?
I have a string with the characters "R$ 1,000.60" and would like to extract only the characters "1,000.60". I tried using regular expression, but I couldn’t reach my goal. I got to this: string…
-
5
votes1
answer1591
viewsWorking with Excel data in C#
I need to create an application that reads a small sequence of data available each in an Excel column. My question is whether the best way is to deal directly with SQL uploading the file and then…
-
5
votes2
answers422
viewsWhat are the possible cases of using a persistent connection?
I’ve been reading about Signalr for the last few days and basically realized that one of its main features is to maintain a persistent server connection with possible clients accessing the server.…
-
5
votes1
answer411
viewsChanging a Dropdownlist via a search
I am creating a registration screen where in a text field I provide a search and the search result will have to appear in a dropdownlist. The project is asp.net mvc4 c# and the code in the view is:…
-
5
votes1
answer355
viewsHow to check if there is an already installed Source
I have a C# program that checks if there is a source already installed or not, but it is not working properly: I’m trying with the following code if (File.Exists(@"C:\Windwos\Fonts\Agency FB"))…
-
5
votes2
answers7885
viewsGrab parameters passed by url on another page
I have this call to another page, passing 2 parameters. Response.Redirect("/frmPVFichaCadastral.aspx?CdProcesso=" + vhdfCdProcesso.Value + "&CdTipoUsuario=" + vhdfCdTipoUsuario.Value) How do I…
-
5
votes1
answer844
viewsFormat date and time and list according to current date
This application has two tables: Students and Occurrences. To show the occurrences I can calmly... Only now I’ve come up with a new business rule: show occurrences by date. So basically it would be…
-
5
votes1
answer529
viewsHow to remove json xml encapsulation returned by Webservice
I created the following method: [WebService(Namespace = "http://myDomain.com.br/PublicacaoService")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]…
-
5
votes1
answer1258
viewsHow do I place a Password field in a Messagebox?
How to enter a field that I can put a password into MessageBox. I could call one form, but wanted something simpler and faster, I would like that when I click on a button it provides a field to put…
-
5
votes2
answers8672
viewsAsp.net Webforms. Timeout error exceeded in SQL Server. How to resolve?
In an application ASP.NET Webforms who uses the SQL Server 2008 I am creating a screen that has a search field that works with requests AJAX a method of a Web Service asmx. To avoid bulk requests I…
-
5
votes1
answer9094
viewsHow to read folder and subfolder files?
I have a function to read the files in the folder, and it’s not working. I need a functional function that reads files from folders and subfolders. Follows the code: FolderBrowserDialog fbd = new…
-
5
votes1
answer1701
viewsHow to get information from another running program?
Updated I thought my question would get lost and I honestly didn’t even see it reopened. But taking advantage that now there was a move to update on my app. It is being developed in C# and therefore…
c#asked 10 years ago Gabriel Tadra Mainginski 707 -
5
votes1
answer1589
viewsDoubt between Any and All in a lambda expression on a list
On a list, I have 12 records (hypothetical) and there is a field called ValorCampoFlag, where this field receives 1 or null, for example. If I do a validation on it and the result if there is at…
-
5
votes1
answer560
viewsReport progress to the interface of an asynchronous method in C#
I have an app Windows Forms. This application will perform some processes that take some time to execute, so I would like to run them in parallel. Follows a little of what I’m trying to implement.…
-
5
votes2
answers1527
viewsHow do I close/close a msgbox via code?
I tried to find out how I could do this, but I did not find anything clear. I want to know if it is possible to close the first msgbox, shortly after 2 seconds. Follows the Code: MsgBox("Iniciando…
-
5
votes2
answers172
viewsHow to use Reflection on a COM object?
I am trying to do a Reflection in a program, however, when the time to pick up the type of the object (Which is necessary for the Reflection) is returning "System. __Comobject", and this is not…
-
5
votes2
answers2303
viewsPrevent an application from being closed by the user through the task manager
I have a C# application that cannot be closed by the user. But even if I eliminate all the means to close the application, including by itself, it is still possible to finish the process by the task…
-
5
votes2
answers1991
viewsChanging the Culture of the System
Developing a system for a Bolivian company, in a windows with Culture pt-BR, some objects like datetimepicker has its internal components according to the language in which the system was installed.…
-
5
votes2
answers475
viewsIs it feasible to use more than one Dbcontext for in the same database?
I’m developing a new application on ASP.NET MVC and searching saw some examples of applications with more than one context. Let’s say my application has several different modules, but all entities…
-
5
votes5
answers4008
viewsRegex take from one point to the other within a text
I have the following text:: From: .... blabla bla Message: blablabalab //linha em branco From: .... blabla bla Message: blablabalab //linha em Branco From: .... blabla bla Message: blablabalab How…
-
5
votes3
answers1828
viewsFormat Strings to RG
How can I format this String: 12345678x for this: 12,345,678-X ? I tried to use the String.Format but I couldn’t. Solved: public string RgFormat(object rg) { string strRg = rg.ToString(); return…
-
5
votes2
answers390
viewsWhy can’t an anonymous method be assigned to a var or Dynamic?
The following code: var mostra = delegate(string x) { Console.WriteLine(x); }; mostra("teste"); The . Net should not identify the var as a Action<string>? And the same for dynamic?…
-
5
votes1
answer2771
viewsHow to get computer information with C#?
As information of the computer where the C#application is running, such as computer name, IP, status of the firewall, if you have antivirus installed, if antivirus is active, etc.
-
5
votes1
answer673
viewsHow I get the sql that Linq generates by debugging VS2013
How do I get the sql that Linq generates by debugging VS2013? How do I do this? I did it and it didn’t work public static List<MontaArvoreAcao> CriarListaArvoreUn(string _uf, string _cidade,…
-
5
votes3
answers10876
viewsRecognize duplicate items in a list
I’m getting a list of items in my action public ActionResult New(List<Itens> Itens) { return View(); } How do I recognize which items are duplicated on that list?…
-
5
votes1
answer11899
viewsHow to send Nfe XML to SEFAZ WS using C#?
I have been doing a lot of research, reading several source codes of other languages and never found answer to my question, which method of SEFAZ web services I should call? I’m working with this WS…
-
5
votes4
answers374
views -
5
votes1
answer163
viewsComposition with fluent interfaces
I’m trying to make a class using composition, fluent methods and I’m having some problems. I would like to access a property of a compositional method through fluent interfaces but I cannot…
c#asked 9 years, 12 months ago Jorn Filho 53