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
-
4
votes4
answers4106
viewsInstantiate class as another class’s Property
I have two classes created within the same namespace, being: public class Pessoa { public int idPessoa { get; set;} public string nome { get; set;} } public class PessoaFisica { public Pessoa pessoa…
-
4
votes1
answer763
viewsChange namespace automatically when changing folder file
I need to restructure the folders of a project, only that there are many files and their respective namespaces need to be changed. Is there any way to change the namespace automatically when moving…
-
4
votes2
answers1552
viewsClause in with lambda
Is it possible to have an IN clause with lambda Expression? Type: context.tabela.Where(a => a.meu_campo_id_tipo_inteiro....) let’s say one in like this: (2,3,4,5) As I put it in the dots?…
-
4
votes3
answers335
viewsLayout Messagebox WPF
How can I customize my Messagebox? Original.. How I’d like it to be (Greater)…
-
4
votes1
answer187
viewsClass protected and public
What is the behavior of a protected class? What is the impact of access modifiers (especially private and protected) on classes, and what are their common uses? I can understand its functionality…
-
4
votes1
answer195
viewsGroup by with Lillo
I have the following tables: **Aula** Id Nome Data **Avaliacao** Aula_Id Aluno_Id Organizacao Didatica To get a Join of the tables I use the code: var result = from a in mdc.SBE_AA_Aulas join av in…
-
4
votes1
answer226
viewsHow to make "OR" between Subquerys using LINQ C#
I would like to implement with LINQ C# (Using Nhibernate as ORM), the following query: return (from t1 in Session.Query<Tabela1>() join t2 in Session.Query<Tabela2>() on t1 equals t2.T1…
-
4
votes1
answer112
viewsThread Safe and its link to Collections
What comes to be thread safe, and what is your connection to data collections?
-
4
votes4
answers1297
viewsDownload excel file
I created an excel file, but now the user needs to download, how can I do ? follows my method : public PartialViewResult ExportarParticipantes(int idPeriodo) { Regex reg = new Regex("[/ :]"); //…
-
4
votes1
answer2717
viewsHow to save and return images with Web Api?
How to send and return images from a Web Api from the Controller of an application Asp.net MVC? In my Controller of the project Asp.net MVC I get from View a picture like HttpPostedFileBase and need…
-
4
votes1
answer2696
viewsHow to make a Viewbag.list receive a List<Keyvaluepair<string, string>>?
How should I pass a list (List<KeyValuePair<string, string>>) for view for ViewBag? My code: string grupo = "ConfigsPortalWebTextos"; List<KeyValuePair<string, string>> lista…
-
4
votes1
answer188
viewsPartial does not render
I have a problem with my application. What happens is that I am not able to render a partial in another view. Here the partial code: @model CEF01.Models.Ocorrencia @using…
-
4
votes2
answers6339
viewsColumn charts (Bootstrap)
I’m developing a system that needs to display column charts. The system is using Bootsrap and MVC 4 C#. Can anyone tell me if there is any framework for creating graphics?
-
4
votes1
answer1055
viewsHow to implement a thread queue to run one after the other?
I have a static method to record logs on my system. public class Logger { public static void SaveLog(string[] lines) { System.IO.File.WriteAllLines(@"C:\...\Temp\ExceptLog.txt", lines); } } The…
-
4
votes1
answer2344
viewsChange style of Windows Forms window
How do I change the style of my window to a Ribbonform. Being that in matter of colors is already quiet. See the image: And now how I use the method CreateParams to change the title and center it…
-
4
votes1
answer275
viewsHow to add new properties to a user using Identity?
How can I create new properties using the Useridentity that comes by default when creating an MVC 5 application? Also, it is interesting to put information that does not belong directly to…
-
4
votes3
answers1352
viewsHow to transform a date into a string format without signals in Datetime?
Examples: string data = "08072013"; string hora = "1515"; Is there a specific method for this type of format? I tried to use Convert.ToDateTime(), DateTime.Parse, etc. and all returned me an…
-
4
votes1
answer2820
viewsRender pages within _Layout.cshtml of other types. Asp.Net MVC 4
I’m basically developing a kind of social network, but I’m having some problems rendering pages inside my _Layout.cshtml page. Html <ul class="dropdown-menu"> <li class="header">Você tem…
-
4
votes1
answer1289
viewsCustomizing Asp.net Identity - Multiple classes as User in Identity
We know that our user on Asp.net Identity is the class named after ApplicationUser I would like to create other classes that inherit from her Why? Why, say I have the Customer, Seller, User class. I…
-
4
votes1
answer148
viewsReflection Emit, what’s the point?
Passing a code to MVC, I saw there was a Label label= new Label(); that was underlined with red, when clicking to see the suggestions, I saw the following: using System.Web.Ui.WebControls using…
-
4
votes1
answer1746
viewsProgress and Time Bar
I would like to know what is the best function in C# that returns with the remaining time when the progress bar reaches the end. I tried this: int restante = Math.Min(progressBar1.Maximum,…
-
4
votes2
answers1637
viewsQuery SQL with 2 subselects for query lambda (or Linq)
select fieldA from TableA where fieldA = 459249 and fieldB in ( select FieldC from TableB where FieldD in ( select cte.FieldE from TableC cte where key= 'ABDC123' ) ) I managed to get to the point…
-
4
votes4
answers313
viewsChanging a random string of characters using Stringbuilder
I have the following variables:: String mascara = "12****3*59**100*"; String numero = "12345768" There is a way to replace the asterisks of my variable mask by the values of my variable number?…
-
4
votes1
answer897
viewsHow to get the publishing version of an application console
I’m having a problem trying to get the publishing version of my application, I searched and found the following answer on SOEN how to show Publish version in a textbox? I followed exactly the…
c#asked 10 years, 4 months ago Tuyoshi Vinicius 4,046 -
4
votes2
answers376
viewsHow do I handle the event generated by the Windows Phone 8.1 back button?
In previous versions it was possible to make such manipulation over writing Onbackkeypress. protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { . . . } However, two…
-
4
votes1
answer4489
viewsWays to check if there is any screen capture software running with C#
I am developing a software written in C# of exhibition of paid videos and need to create protections to avoid as much as possible that buyers distribute the videos irregularly. For now I need to…
-
4
votes1
answer1387
viewsLogin screen with Membership and mvc5
How do I login using Membership and mvc 5? By the way, how do I use Membership?
-
4
votes1
answer103
viewsDatareader blocks using Datareader "Close()"?
I have a little doubt regarding Datareader’s inside using blocks. If my Datareader object is inside a using block, will it be closed at the end of that block? Or do I have to insert the Close…
-
4
votes1
answer133
viewsError in database query with Linq
Good night! I am trying to perform a query in a mysql table, using English, and present this result in a gridview for the user. I have the table below: I’m not searching all columns of this table,…
-
4
votes1
answer11696
viewsHow to resume default settings in the Visual Studio editor?
Was using the Resharper in trial period and after the end of trial time I did not want to acquire and then uninstalled by Control Panel / Programs and Resources, as I found no option in the Visual…
-
4
votes2
answers285
viewsDetect generated event in another class
I have a class (in VB) that returns an event of TimeOut, that is, if time runs out it returns an event content with a string with the data I need using Raiseevent. How can I treat this event in the…
-
4
votes2
answers1514
viewsView Razor to PDF
I need to convert Views of my MVC 5 application to C# using Razor to PDF. I already searched, and the free tools depend on iTextSharp, which I searched for has a different marking. But I need to…
-
4
votes2
answers3616
viewsHow to save the logged in user ID
I am using in my Windows Authentication application. I have a controller where the user should register their professional experiences. However, the way the application was made, I need every time I…
-
4
votes3
answers1517
viewsHow to use Skip and Take with Pagedlist Helper
I would like to make the pagination, but using Skip and Take on my LINQ not to fetch all results. Currently my code is like this: public ViewResult Index(int? page) { var grupos= from s in db.grupos…
-
4
votes2
answers839
viewsHow to check if a class implements a C#interface?
How to check if a class implements an interface? For example, I want to include an if that checks if an object is of the Idisposable type. How to do? I tried something like : MinhaClasse meuObjeto =…
-
4
votes2
answers396
viewsHow to optimize the color palette of a Gif?
I have a method that generates images through an array of bytes that I take from the database. The generated files are between 15 and 130 kb in gif format, they were bigger but slightly decreases…
-
4
votes2
answers2764
viewsWindows Forms Start with Operating System
How do I make the user have the option to choose whether the system (system Tray c#) will start with the OS or not through installation in Wizardsetup (Visual Studio 2010)?
-
4
votes1
answer1838
viewsHow to Use "Not Exists" in LINQ?
I am trying to translate the query below, in LINQ, but without success, someone can help me? SELECT * FROM PESSOAL A WHERE NOT EXISTS ( SELECT Chapa FROM PRODUCAO B WHERE B.Chapa = A.Chapa AND…
-
4
votes2
answers1970
viewsUse PIVOT operator without aggregation
I have the FAULTS table with the following columns: CREATE TABLE [dbo].[FALTAS]( [Id] [int] IDENTITY(1,1) NOT NULL, [Matricula] [int] NOT NULL, [Dia] [date] NOT NULL, [Situacao] [varchar](50) NOT…
-
4
votes2
answers14235
viewsHow to check if there is an element inside a list?
I need to check if there’s a status on my list.. I am passing a parameter (a state code) and the method will see in the list if that state exists...something of this kind in C#: if…
-
4
votes1
answer155
viewsSyntactic Reader (Extension of Visual Studio 2013)
By syntactically reading a language in a Visual Studio extension project I can already read the following: <span class="myclass"></span> It is relatively easy to manage read states…
-
4
votes2
answers141
viewsDisplaying massive amount of data
From the moment we work with a very large amount of data(eg: more than 3 million records), and we need to display this data on the screen while the user uses the page, always having the best…
-
4
votes1
answer139
viewsHow to restrict inherited types from a hierarchy level?
Given the hypothetical model below: public abstract class Veiculo { public Motor Motor { get; set; } } public class Aviao : Veiculo { } public abstract class Motor { } public class MotorCarro :…
-
4
votes1
answer201
viewsCloud IDE for C# ASP.NET development
Does anyone know any IDE in cloud for ASP.NET C# development? I read something about a CODERUN, but I think it’s no longer active, someone has some suggestion?
-
4
votes2
answers6760
viewsError " An error occurred while Processing your request. "
I developed a MVC C# application for JSON reporting in my localhost it works normally, to query because it takes 2 to 3 databases depending on the report, but when I host the application in Azure,…
-
4
votes2
answers1234
viewsHow to generate a file in the same exe directory
I am generating an XML file and I want it to generate with exe. XmlTextWriter writer = new XmlTextWriter(@"c:\dados\filmes.xml", null); instead of putting the directory to save with exe.…
c#asked 9 years, 12 months ago Bruno Rodrigues 394 -
4
votes1
answer350
viewsWhat’s the difference between using Savechanges() only once after adding data via a foreach and using inside the foreach?
I’m entering an average of 50,000 records into the database via the Entity Framework. And I got a question regarding the following code placements: in the first (1) placement, I use a foreach…
-
4
votes2
answers490
viewsHow to persist the status of a queue of requests?
I am working on a C# application that requires a row of items of the type Pedido. Basically whenever a new order is created it is queued and the application shows the orders in sequential order that…
-
4
votes1
answer309
viewsLock or release a controller according to some condition
I have a controller that should only be accessed if an attribute in my table is "true". Is there any way at the time the user clicks on such a link, check if the attribute is true, and only then…
-
4
votes2
answers1819
viewsLogin using Entity with password encrypted as varbinary
I did the user password encryption and in the Password field of my table I went from Varchar to Varbinary, in the web part of my system it is all right only that in the windows part I am using the…