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
answer557
viewsHow to get command line parameters / file path
I am developing an application, and accurate by parameters/commands next to the file path. For example, these flags: C:/caminho_do_arquivo -r C:/caminho_do_arquivo -v And in the code there would be…
-
5
votes1
answer543
viewsParameter of any type in method
I am building a method and would like it to extend into any type. For now I am using string but I would like the same to work for int, float, double and datetime. public static bool isNotNull(string…
-
5
votes1
answer1638
viewsWhat’s a POC in C#?
I received a request to make a POC email, but before doing so I would like to know what a POC in C#. If there is content on the internet for the same. P.S.: I don’t want the solution, I just want to…
-
5
votes1
answer263
viewsHow do I sort Lambda by a List property?
I believe this has been asked before. I researched but did not find. I’m having trouble with this consultation, specifically in charge ThenBy that tries to sort the sub-list of objects. I know it is…
-
5
votes1
answer1108
viewsWhy @Html.Checkboxfor returns "true,false"
In the construction of my View, I have a field of the kind: public bool? RegistoGesOleos { get; set; } Who I represent using Razor as: @Html.CheckBoxFor(model => model.RegistoGesOleos.Value) Now…
-
5
votes1
answer1710
viewsConnection error
I am creating a Windows Forms application using C# and am having a problem connecting to SQL Server CE 4.0. The application database is in the folder AppData of the logged-in user. To get the folder…
-
5
votes2
answers169
viewsExpand Object to Bson
How can I build a parse expander Object for Bson? (Vs 2013 - C# - Mongodb)
-
5
votes1
answer216
viewsYield does not return data
When calling the method, an HTML component enumerable should be returned. I’m using the HTML Agility Pack to read an HTML file. The same method works as expected when removing the yield and add…
-
5
votes1
answer248
viewsI can’t make the character of Nightmare disappear after he’s dead
I’m following all the steps of a tutorial on the creation of the game Nightmare, videos made by the channel "Playing with Nils", but after following all the steps, when I run the game and then I…
-
5
votes2
answers6301
viewsRemove an item from a List<>
Well, I have a method that I consult at my bank and compare with a List<Carros>. My intention is, for every item that contains as much in my query as in mine List<Carros>, I remove the…
-
5
votes1
answer2184
viewsNfs-e Belo Horizonte XML signature error
I am developing the integration of a system to issue Nfse to Belo Horizonte are happening 2 situations that only with this city that I developed are happening, we have integrated several…
-
5
votes1
answer340
viewsWhat is the correct way to declare a chain of methods and prevent the same method from being used outside the scope?
In my last questions I was creating some methods to automate some queries. It’s legal, but now I need to control access to methods by specifying a sequence. When using the method Select(), i cannot…
-
5
votes1
answer1324
viewsC# Image and PDF Manipulation
I wonder if there’s a way to turn multiple images into a single PDF file. On my app I’m already pulling their address.
-
5
votes1
answer2655
viewsMy project no longer opens
My project was working perfectly. I went to open it now and gives me this error: When I arrived my grandson was with my notebook, but I don’t think he (3 years) would damage. It’s more likely to be…
-
5
votes1
answer795
viewsGood practice with . NET MVC
I have an ASP.NET MVC application and would like to know what good practices microsoft indicates in the organizational aspect of the solution, using the latest technologies such as ASP.NET Identity.…
-
5
votes1
answer406
viewsHow to map a TIME-like column in Entity Framework 6?
I am using this mapping to a SQL Server DATETIME field: Property(X => X.DatNascimento).HasColumnName("DAT_NASCIMENTO").HasColumnType("datetime"); But I have another field that is only TIME that I…
-
5
votes2
answers490
viewsDoubts about the use of delegates
I still have not been able to fully absorb the use of the delegates, at what point I really should use a delegate and why of their construction. Then I ask the following question to the community.…
-
5
votes2
answers3902
viewsC# - How to remove the Maximize bar, Minimize, but only keep one Close button?
I created a graphic component and wrote a command line that removed the control bar from the graphic component, but all the buttons are gone. Is there any way to just let the Close button? Or I’ll…
-
5
votes1
answer357
viewsHow to manage Session with Session in C# desktop and non-web applications?
I can’t find an example of using the Session object for desktop applications, all I find are for applications made in C# for the web with Asp, etc. Does anyone know how to check if a user is…
-
5
votes1
answer608
viewsDifferentiate interface "instance" class instance
Got some way of differentiating v1 of v2 in the code below, by reflection or other method? var v1 = new MinhaClasse(); IMinhaClasse v2 = new MinhaClasse(); I want to run a method only if a variável…
-
5
votes1
answer1334
viewsHow to create a window without using the GUI builder?
I’m starting to study C# and just like in Java, Ides provide resources that make it possible to build Guis easily by dragging components. The netbeans has a powerful construction tool where it is…
-
5
votes3
answers203
viewsReturn Time.zone.now in C#
In ruby on Rails you have a command Time.zone.now that returns me the date and time in this format => Sun, 18 May 2008 14:30:44 EDT -04:00 I need to get that same time zone return only on C#…
-
5
votes1
answer1261
viewsAccess webcam to take photo
How can I have access to webcam to take some photo and upload directly to my server? Is there an API that helps me?
-
5
votes1
answer104
viewsHow to read, search and change file by bytes?
Does anyone know how to find more bytes after I found the byte sequence of my variable? for example: in the file will look like this: 6261725610 I’ll look for that: byte[] findBytes = { 0x62, 0x61,…
-
5
votes1
answer820
viewsProblems hiding/displaying div with Javascript
I have a relatively simple problem, but I cannot find a quick solution: I have a dropdownlist which determines which div will be displayed, and the moment the page is loaded for the first time, it…
-
5
votes2
answers552
viewsDividing 1/2 in C#
In some videos on numberphile about the Zeno’s Paradox the teacher of the video tried to explain how this paradox worked using hands to hit Palamas (I do not know how to explain this but I will…
-
5
votes1
answer1236
viewsHelp - C# how to update combobox? type autocomplete
First I am developing a C# system and using Sql Server as a database. I would like to accomplish the following task: When something is typed in the combobox I update the itself, by means of a search…
-
5
votes2
answers957
viewsC# - How to make a lambda filter with more than one field?
My List: public class Carro { public int Ano; public double Valor; } List<Carro> Fiat = new List<Carro>(); Fiat.Add(new Carro {Ano = 2000, Valor = 5000 }); Fiat.Add(new Carro {Ano =…
-
5
votes3
answers1370
viewsOne button code to undo an action in C#
Hello, I am developing a Bingo software for the Church that I attend. When you press a button of any number, it will appear in the Picture Box. As shown in the following image. Now, realize that…
-
5
votes1
answer601
viewsCan foreign key be null in Entity?
I’m having a hard time in a project. I created two tables (Union and Schoolhouse), whereas the PK table Union is FK on the table Schoolhouse. But this FK may be void, i.e., the Schoolhouse may…
-
5
votes1
answer1820
viewsHow to convert string to double without rounding error?
Because the following command: Convert.ToDouble("199998,99") Results in: 199998.98999999 Already the command: Convert.ToDouble("199998,98") Results in: 199998.98000000001 ?…
-
5
votes1
answer1426
viewsC# App.config - Change BD address at installation time
I have a C# desktop application that when installed on a pc, must access a Mysql BD that is on another machine. The BD server address is configured in the file App.config . At the client’s request,…
-
5
votes1
answer1837
viewsWhat are the differences between a Datatable and a Datareader for Mysql queries in C#?
I am creating a C# project with Mysql, my connector follows the standard Singleton and use Mysqldatareader to recover the table data and popular a List so far ok. My problem started when I had to…
-
5
votes2
answers2885
viewsBlocked cross-origin request
Hello, I am trying to load a page from another application into a div of my application using the jQuery load but my application is not loading the page and shows the following error message:…
-
5
votes1
answer206
viewsDoubt with Codefirst Entityframework
I’m starting in Entity Framework and I have a question regarding Codefirst. Why I have to use as virtual some properties like the example below? [Table("Grupo")] public class Grupo { public int ID {…
-
5
votes3
answers1861
viewsC# MVC Run Function (Logout) When Closing Browser
I am in a service system and need a help to understand how I can call some event (Javascript / jQuery / Or not) at the time a user closes the browser without logging "correct" by the system... Att.…
-
5
votes2
answers213
viewsValue priority data ordering using LINQ
I have a "status" table with the following values: ID 1 = Ativo ID 2 = Novo ID 3 = Excluido How would you return a list of objects (that have the status object) prioritizing, coming first, those…
-
5
votes1
answer1567
viewsError using Viewbag in Dropdownlistfor ASP NET MVC
I have a Dropdown that lists the categories of my system, but when I submit the form without choosing a category, it gives a server error saying that the Value cannot be null. I put a validation…
-
5
votes1
answer76
viewsHow to block menu buttons, when a form has not been saved yet, is it possible?
I’m new around here. I’m starting in c# and came across the following question: I have a form, where I haven’t given a post still, and I didn’t want to let the user leave this screen without saving.…
-
5
votes2
answers243
viewsCast problem in a generic method that receives an array of Enum’s (Enum[])
I intend to make a generic method that receives a enum[] and that a string representing the items of array comma-separated. public static string ToSeparatedCommaString<T>(T[] enums) where T :…
-
5
votes2
answers780
viewsMulti-tenant system with the possibility of "customization"
I am raising knowledge for the creation of a multi-tenant system. I’ve been taking a look at some references from MSDN, SOEN and SOPT, as well as several websites. Although I have read the…
-
5
votes1
answer73
viewsIdentification of regions google maps - Javascript
I have a list of latitudes and longitudes and I would like to find out in which region of the country such latitude/longitude belongs.
-
5
votes3
answers2845
viewsImage to byte[]
Hi! I’m using Xamarin.Forms to make an app. So, I need to save images to Parse. To do this, I need to convert the images to byte[]. Any idea how I can do this ? I’ve looked on the internet but none…
-
5
votes1
answer684
viewsIs it possible to use composite key for Entity Framework with Model First?
I have the modeling down and will need to map composite keys like the Embedded id of Hibernate, but in the Entity framework using the model first, it is possible ?…
-
5
votes2
answers509
viewsIs using version control on the production server a good practice?
In the company where I work today, we have a Web system (C# ASP.NET) where we use the Team Foundation Server 2013 in the development environment. On the production server we don’t use any version…
-
5
votes5
answers3375
viewsConsole Application without showing console window
I have a Console Application in which I use to run routines of my system. I am running this console from the Task Scheduler, every time it runs it flashes on the screen. It opens, executes the…
-
5
votes2
answers1831
viewsHow to recover the description of an enumerator?
I have the following enumerator public enum MeuEnumerador { [Description("Descrição do item do enumerador")] Enumerador1 = 1, [Description("Outra descrição")] Enumerador2 = 2 } How do I get the…
-
5
votes1
answer777
viewsData formatting works on Chrome and does not work on Internet Explorer, or vice versa, with MVC C#
If I wear the model [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd'/'MM'/'yyyy}")] public DateTime data { get; set; } Works perfectly on I.E. but doesn’t work on Chrome. When…
-
5
votes1
answer1255
viewsC#FTP Connection Failed
I’m developing an application Console in c# which performs connection to an FTP server (or at least should), I have the following code: Class Ftpconnection class FTPConnection { private Connection…
-
5
votes2
answers506
viewsReceive null int in Razor (@Html.Textboxfor)
I have an object Carro and I have a whole-type, annulable property called AnoInspecao. When creating, I can create a car object with the year of null inspection (without typing anything) and persist…