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
-
3
votes2
answers2851
viewsEnable/Disable Button according to Checkbox value in a Datagridview
A form in an application Windows Forms with C# displays a DataGridView with Checkbox. When one of Checkbox is marked I want to enable a certain button. If any Checkbox is marked I want to disable.…
-
3
votes2
answers825
viewsXML/C# - How to create tags containing other tags within it
Allah Personal I have the following problem: I need to create an xml file of products, in which each product will have a group, so far so good, just by adding the data it creates the product tag and…
-
3
votes2
answers104
viewsUnderstanding a delegate’s lambda parameters in a function
I have the function below. I would just like to understand who is X and what values it is reaching in the course of the function. I could not catch the debug. You don’t have to say the exact values…
-
3
votes1
answer688
viewsHow to capture text that another console program writes on the screen
My Windows Forms program runs another console program. This second one writes messages on the screen while running. I want to know if you can prevent the execution of the other program from opening…
-
3
votes1
answer247
viewsError reading from XML
I am wanting to read XML nodes and my code below is generating exception: XmlDocument arquivo = new XmlDocument(); arquivo.Load(@"Z:\Área de Trabalho\Windows XP.xml"); // Esta linha abaixo gera a…
c#asked 9 years, 2 months ago Marcelo Nascimento 403 -
3
votes2
answers5849
viewsHow to cut a string?
Example: nome = "Josénildo da Silva Ramos do Carmo"; Cut to have up to X characters, and look like this: nome = "Josénildo da Silva "; In this case I cut to 20 characters. How do I do this in C#? I…
-
3
votes1
answer147
viewsDilemma to the popular datalist
I have a problem that I don’t even know what to call. But I will try to express this problem here. Here’s the thing, I made a pagination in my datalist with the following code: private void…
-
3
votes2
answers398
viewsCreate modules using Unity (Ioc)
In an application using a multi-tier (n-layer) architecture, we have the infrastructure layer where we use an Ioc container to record the required dependencies. In a prototype I’m working on, I’m…
-
3
votes3
answers877
viewsAsp.net serving statics files
I have an application in mvc3 (Asp.net 4.0, dotnet 4.0), running at iis8 (but also running at iis 7 and iis 7.5). Inside the application I have a folder called /dados, example…
-
3
votes1
answer477
viewsTurning SQL Code to LINQ
With transforming codes SQL for LINQ? Questions are in the code comments on LINQ: Code SQL: Select CL.NomeDeGuerra as Colaborador, CL2.NomeDeGuerra as Gerente, Concat(C.Codigo,'-',C.NomeFantasia) as…
-
3
votes1
answer636
viewsCOM Interop with Client and Server
Hello, I have a DLL to encrypt data. I need to use the Component Object Model(COM) Interop to be able to communicate two applications and both traffic the encrypted data through this DLL. Searching,…
-
3
votes2
answers684
viewsFiltering Kids Collection in Entity Framework with Lambda
I have a case where I need to bring all the items of the parent object where you have a certain condition, example: ctx.Pai .Where(x=> x.Ativo == true) .Include(Filhos)…
-
3
votes1
answer57
viewsWhat are the differences between these Nuget packages?
I use the Javascriptengineswitcher.Msie package in my webapps on Asp.net mvc, I found 2 more Javascriptengineswitcher packages what’s the difference between them what the pros and cons are?…
-
3
votes1
answer269
viewsError importing DLL
I have a DLL made in C#. When importing it to be used on another computer, I find the class. However, her methods are not published; Follows my code: using System; using…
-
3
votes2
answers247
viewsDoubt about Security, Authentication and Authorization
Hello, I’m having a hard time setting up an architecture in the application security related part. I need only logged in and duly authorized users to have access to certain functions of the…
-
3
votes2
answers2804
viewsHow to pass commands to a . exe via C#?
I wanted to call through an application in C# a .exe any and pass them some commands as soon as it opened. For example, what I want to do at the moment is that the program opens, give three Tabs and…
-
3
votes3
answers2241
viewsHow to create nonexistent columns in a Datatable?
Here is my query: select u.nome as analista, s.descricao as situacao, count(*) as qtd from tb_projeto p inner join tb_usuario u on u.id_usuario = p.id_usuario inner join tb_situacao s on…
-
3
votes3
answers1719
viewsVery slow C# and MVC site
I developed a site in MVC and C#, but after deploying in Gogaddy server I have noticed that the first access is very, but very slow. I practically check if there is a logged in user, if I do not…
-
3
votes1
answer4215
viewsError while decrypting string
I have a method to encrypt and decrypt data. I tested it in the Application Console and it works perfectly. When taking this method to the controller, I get following error: Invalid length for a…
-
3
votes1
answer3577
viewsHow to check if a tag exists in an xml?
// Obtém a tag "tags" if(xmlDoc.ChildNodes[1].ChildNodes[1].ChildNodes[1].SelectSingleNode("tags") != null) { } I am running an Xml and in some we do not have this tag "tags" and error. Does anyone…
-
3
votes1
answer537
viewsInternationalization, Localization and Globalization
I have a project that needs to work with internationalization, where the web application needs to be available at least in portuguese and english, and perhaps also in Spanish. My biggest difficulty…
-
3
votes1
answer82
viewsBring selected manually filled combo
I’m having difficulty creating a combo of "Enabled" and "Disabled" passing the value of the bank to bring it filled. In my controller, I created the following code: In my View, following code: The…
-
3
votes4
answers1209
viewsButton with pause function
I have a little app that inserts images into the database. There are many images and sometimes I need to stop the execution for a period and continue at another time not to disturb the client’s…
-
3
votes1
answer769
viewsHow to kill a specific user process on Windows Server?
I have a C# application that at the end needs to kill a user process that ran, but as I am in a Terminal Server (Windows Server) and there are several users logged, when I put the command to kill…
-
3
votes1
answer231
viewsTransforming Query into Linq
I need to turn this query into Linq: select B.Nome from Gestor A inner join Entidade B on A.UniaoEntidadeId = b.EntidadeId group by B.Nome HAVING COUNT(A.EscolaId) > 0…
-
3
votes1
answer425
viewsPopular datagrid with threading
I am contracting a Windows Form application. I am not getting popular my datagrid with a threading, appears the following error: "Invalid threaded operation: control accessed datagrid of a thread in…
-
3
votes2
answers607
viewsForeach duplicating the data
I possess 2 foreachs, to search for dates on ViewBags, where I return both in a select. But for each item of the first foreach, it makes a complete loop in the second, thus doubling the values, for…
-
3
votes1
answer743
viewsHow to change a property during a LINQ query?
Is there any way to change in the LINQ query a property of the query itself? Ex.: I’m doing a consultation on a List<Cliente> and I want all customers whose NomeFantasia begin with * have the…
-
3
votes1
answer1008
viewsInstall database together with C#
I am finalizing an agenda of the meeting room that will be in the company reception, so I opted for the base to be locally and not networked. I intend to use Mysql or Sqlite. Is there any way I can…
-
3
votes1
answer705
viewsDevelop standard Razor template - ASPNET MVC
I am with an ASPNET MVC5 project using C# which by design definition was agreed that the Layout of the pages structure would be stored in the Database. Within my _Viewstart would be referenced my…
-
3
votes4
answers4241
viewsHow to get the amount of records in a query in Sqlite?
I am listing the records of a table with the code below: SQLiteCommand comando = new SQLiteCommand("SELECT * FROM Cadastro " +filtro, conn); SQLiteDataReader receber = comando.ExecuteReader(); But…
-
3
votes3
answers162
viewsRelationship Have-one in C#?
I tried to do a have-one relationship in C# and I’m not getting it and I don’t even know if it’s recommended to do. Follow my error code: System.Nullreferenceexception Undefined object reference for…
-
3
votes1
answer1091
viewsGeneric object reference error
System.Nullreferenceexception: Undefined object reference for an instance of an object. This error is giving in the following code snippet: Arquivo arquivo = new Arquivo(); ArquivoVersao versao =…
-
3
votes1
answer1629
viewsError loading Antlr3.Runtime
Today I had a power outage problem and when restarting the computer a complete scan was performed. Apparently generated some errors and I believe that one of them is related to the problem that…
-
3
votes1
answer228
viewsAccordion in Windows Form?
Hello good afternoon / evening I’m new with c#, Guys someone there has an idea of how to get the accordion effect in Windows Form equal in HTML using jquery
-
3
votes1
answer238
viewsPerformance in string filter queries vs foreign key
I’m working on a project Asp.Net MVC 5 using code first and all entities have a property called UserId of the kind string. When I will make queries filtering by a certain user(Asp.Net Identity) I do…
-
3
votes3
answers285
viewsHow to serialize a class to file in C#?
How do I serialize a class to a C file#? I have a class [Serializable] public class MyClass { public int MyNumber { get; set; } public string MyName { get; set; } }…
-
3
votes1
answer965
viewsHow to simplify a foreach by a Linq expression - Lambda
Performance is not an issue in my project, I want to know a simpler and readable replacement for my foreach using Linq and Lambda (if possible). // 'DiscoVirtual' é uma classe // 'this.HDs' é um…
-
3
votes2
answers85
viewsFixed and unique value on Android in Unity 3D
I’m having trouble getting a unique and fixed value in C#, I need to get a value like this, for security reasons of my software. I’ve tried using the SystemInfo.deviceUniqueIdentifier, but…
-
3
votes1
answer801
viewsHow to use multiple classes as User in Identity - Asp.Net Identity
I want to use 2 classes as User in Identity and could not see this change in code. Let’s assume that I will use the default class "Applicationuser" that generates an "Aspnetusers" table and I want…
-
3
votes3
answers2918
viewsFormat a string with time
I’m trying to format a string that already has date and time, but this string just gotta get the time I’m trying this way but it doesn’t work: Recovering from Data Base. string dtSolicitacao =…
-
3
votes2
answers135
viewsJavascript - Populate a field with paragraph
I am developing a javascript to popular a text box, but I came across a situation that is causing me difficulty. Need popular with this message for example: TEST TEST TEST But I’m not getting to…
-
3
votes1
answer758
viewsPass Type parameter for generic Runtime method
I have a method I use to deserialize data: public static class CustomJson<T> where T: class, new() { public static T Deserialize(string data) { try { return string.IsNullOrEmpty(data) ?…
-
3
votes1
answer112
viewsRecommendations for comments on an interface and its contracts
Every day I come across this situation when I will insert comment for an interface and for a class. I wonder if I should use the same interface comments and their contracts, in class and their…
-
3
votes1
answer634
viewsHow to convert latitude/longitude to Double in C#
I have a problem because I have a variable of the type string and I need to convert to the guy double without losing the "dot". Example: string latitude = "-8.709006" when converting is equal to:…
-
3
votes1
answer1543
viewsCorrect use of async and await in Asp.Net
I am creating an asynchronous method for sending Emails from the opening or changing of the object, but when calling the method of sending email I have to put the await in front and the return of…
-
3
votes2
answers642
viewsExecute server method when closing the browser
I need the user to close the browser or the page tab, update the status Logged in that is in the database (to control user access). For this use the following Method JavaScript:…
-
3
votes1
answer38
viewsTaking all files with the name started by something in a directory
I want to take all the files started by something, for example "javaw" in a given directory. Thanks for the time.
c#asked 9 years, 1 month ago David Amaral 81 -
3
votes1
answer1075
viewsMethod that recognizes the touch of the MOBILE SCREEN C#
I’m doing an augmented reality app with Unity and vuforia. I created a class that makes the ball bounce, now I need to insert this ball movement to a touch on the mobile screen... Does anyone know…
-
3
votes4
answers11622
viewsIs it possible for a Javascript function to call a method that is in the Behind code of the page?
I have a button and I wanted to program the click of it, and when I wear a <asp:Button> I program the click of him in the code Behind. Now I’m wearing a button normal. I know almost nothing…