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
votes2
answers755
viewsWhat is #pragma c#
By maintaining a code of a web service I came across the following code snippet: #pragma warning disable 1591 Searching for its meaning, I did not find anything in Portuguese that was easily…
c#asked 7 years, 4 months ago LP. Gonçalves 883 -
5
votes2
answers2096
viewsMysql and C#inheritance modeling
I have a question about modeling a Desktopapplication system in C# with Mysql. Essentially I will have the entities Customer, Supplier, PF and PJ. PF can be a customer or supplier. And PJ can also…
-
5
votes1
answer86
viewsHow to know which exception can be cast in C#?
If in Java I invoke the method void cadastra() throws SQLException for example, I will be required to add a block try catch or to "relaunch" the exception that can be launched by this method. That…
-
5
votes1
answer503
viewsHow to write an asynchronous method?
I have the following method: public void Contar() { int numero = 1; for (int i = 0; i < 100000; i++) { numero *= i } return numero } Supposing that the method Contar() take time to lock the UI of…
-
5
votes2
answers4277
viewsapplicationx-www-form-urlencoded with Httpwebrequest
I’m making a system to authenticate the Token (derived from the credit card) next to Cielo. This token has special characters like + Cielo receives the data via XML. I made the following code to…
-
5
votes1
answer92
viewsError when comparing string
I’m trying to finish my last few pieces of code and I need to check the value of a string, but I can’t find any example on how to handle. I tried this code, but error appears: Error 1 Cannot…
c#asked 7 years, 2 months ago Helder Da Silveira Ventura 125 -
5
votes1
answer1790
viewsImport Excel to Sql Server C#
I need to import a file excel for a table SQL. However, I need to pick up the lines and go between them because it won’t be all the information I will get from excel. I have exactly what I need but…
-
5
votes1
answer376
viewsWeb service hosting equals a website with pages?
I am developing a mobile application with Xamarin. This application is a screen to authorize or not discount above authorized by sellers. So I have a web service that goes into the bank and takes…
-
5
votes2
answers739
viewsMVC Custom and Friendly Routes | Create a Route with only one parameter in the URL
To create a path where only the single parameter would be displayed? For example, my route is currently like this: routes.MapRoute( name: "RouteEvent", url: "{ProdutoNome}", defaults: new {…
-
5
votes1
answer41
viewsRepresentation of an entity in my class
I got that field on the bench: ID_LIBERACAO and in my class of mastery I have so: [Table("Tabela")] public class Tabela [Key] [DataBaseGenerated(DataBaseGeneratedOption.Identity)] public int…
-
5
votes1
answer917
viewsHow to use multiple App.config
How to use more than one App.Config? I have a Solution with several projects. In each project there is an App.Config. When I try to read a key, either by AppSettingsReader or by…
-
5
votes1
answer92
viewsWhat is the equivalent of the PHP array_map in C#?
In PHP, can create a new array based on a array already existing, using the function array_map. With it, I can define a callback that is responsible for the definitions of each value that will be…
c#asked 8 years, 5 months ago Wallace Maxters 102,340 -
5
votes1
answer303
viewsPass object to Webservice
I’m starting the development using Webservice + Windows Form and I did some silly methods passing parameters, however, I came up with the idea of passing an object as parameter where the Web Service…
-
5
votes2
answers4066
viewsHow to know the number of lines a large file has in C#?
Well, I’m starting now in C#, but I already have a great experience with PHP and I know more or less Python. And the means that I use to appeal is to do something that I found difficult to do in a…
c#asked 8 years, 4 months ago Wallace Maxters 102,340 -
5
votes3
answers419
viewsHow to turn a bool into int?
I’m trying to do the following: if the guess value (_TextValPalite) is enabled then it will check that this number is not different from a minimum value and a maximum value. Ex: between 1 and 10 I…
-
5
votes3
answers5352
viewsHow to convert from Text to Number via code to EXCEL in C#
I have a program that reads data from a text file and exports it to an excel report. I have a problem in the transcription of the numbers, in the txt file I have data in this format: 8,000000 this…
-
5
votes1
answer762
viewsHow does Sqlbulkcopy work?
I’m using in my class project SqlBulkCopy to mass input data. Everything has worked perfectly, but in recommending this to my co-workers, despite proving the efficiency, questioned about the…
-
5
votes1
answer610
viewsXamarin - Sqlite Join
I’m creating an app on Xamarin, which generates a sales order, and stores on mobile. I’m using Sqlite to store the data, but I’m having trouble making a Join between my Order Items table, and the…
-
5
votes1
answer66
viewsParameterizing Dataset in C#
I created a search screen with a textbox, one button and a gridview. I would like the search results to appear on this Gridview but I can only do that with one Dataset. In this case I needed to find…
-
5
votes1
answer183
viewsPass arguments to the property getter
VB.NET allows you to declare parameters in the property getter Public ReadOnly Property Propriedade(param As String) As String Get Return param & "!" End Get End Property It’s a strange feature…
-
5
votes1
answer1032
viewsDependency Injection in . NET Core
I am migrating a Webapi project with . NET Framework 4.6 to . NET Core. In this my project I use Unity to do Dependency Injection: var container = new UnityContainer(); DependencyResolver = new…
-
5
votes2
answers1451
viewsI need to know when the user uses semicolons in decimal numbers
I am developing an exercise whose result is different in scenarios that the user uses point or comma to put his decimal number, in this case I put as variable of type double…
-
5
votes1
answer446
views -
5
votes1
answer123
viewsProblem when trying to connect to a Signalr+Angularjs Hub
I have a little project with WebApi,SignalR and Angularjs where I do some queries and inserts in real time. Everything works fine when I start the file index.html right when running the application,…
-
5
votes3
answers219
views -
5
votes3
answers287
viewsOut Of Memory when running a Getfiles in a very large directory
Currently I have a directory with several subdirectories that have more than 3 million files. I need to map only the directory where these files are. And this mapping should be separated by the file…
-
5
votes2
answers650
viewsReference class Syntax Razor C#
I have a class where I have saved a configuration key being key and value, but I need to take the value of this key and move to my page cshtml. I’m having a hard time with this. I have already…
-
5
votes1
answer330
viewsShuffle playing cards
I need to make a kind of "Mini-pife", but I’m not able to create the method to shuffle the cards, someone can help me? public class Baralho { public Carta[] Cartas { get; private set; } public…
-
5
votes1
answer159
viewsPurpose of lambda syntax in function/method
In some cases a function/method contains only one line in its scope, see the illustrative example: static int Soma(int a, int b) { return a + b; } Meanwhile, to a new feature in C# 6.0 that allows…
c# function lambda-expressions characteristic-language methodasked 8 years, 2 months ago gato 22,329 -
5
votes1
answer346
viewsWhen should I instantiate a class?
I’m having second thoughts about the best time to call for instantiate a classe. Should I do it at the beginning, before the builder, at the constructor or at the time when we will make use of some…
-
5
votes1
answer1276
viewsEncrypt App.Config
I’m trying to encrypt my Connection string, that’s in my app.config. After reading some forums, I saw that 2 methods need to be created: class proteger_app { public static void Criptografar() {…
-
5
votes1
answer776
viewsAllocation Space for Mysql Fields
First I create the model in my application, then the Entity Framework generates the SQL for the table creation. The first statement generates a column with the type varchar(20), the second generates…
-
5
votes1
answer772
viewsEnum as Object Value in DDD
After many searches on the internet, I came across many divergent opinions... In my application, I created the enum EstadoCivil {Casado = 1, Solteiro = 2, Divorciado = 3}. It can be classified as an…
-
5
votes1
answer2775
viewsLoad Combobox from a List<>
I’m trying to load items into one ComboBox from a List<>, worked out however, later I would need to get the code referring to the selected item, but it is not working. The code to load the…
-
5
votes4
answers96
viewsWhat is the best solution ? Getbyid with a non-existent id in the BD
I’m making a call in my Pository but CPF does not always exist in the BD. When it does not exist in the database I get the following error. Repository public VendedorModel GetById(int CPF) { using…
-
5
votes2
answers812
viewsGet previous element in foreach
It is possible to take an element from the previous to current position using the repeat loop foreach? For example, whenever I need to take an element previous to the current position of the loop, I…
-
5
votes2
answers3367
viewsWhat are the differences between Viewbag, Viewdata and Tempdata?
I was researching how to pass data to a view, or rather, persist the data of a controller to the view. I would like to know among the 3 forms cited in the title: What are the differences between…
-
5
votes2
answers379
viewsHandle 404 error without using Try/catch
I have the following code snippet that makes an HTTP request, only that sometimes the URL does not work, then will be launched an exception by framework. HttpWebRequest request =…
-
5
votes1
answer699
viewsHow does MVVM actually work?
How does MVVM actually work? What are the responsibilities of Viewmodel and Model? I’m implementing a standard project MVVM some time ago, but now some questions have arisen about the. Where to…
-
5
votes1
answer1545
viewsSystem Error.Indexoutofrangeexception
I’m having mistakes in Titular.Text of this form and do not know how to solve. public partial class Titular : Form { private Conta[] contas; private int quantidadeDeContas; public Titular() {…
c#asked 8 years, 1 month ago Graziela Glória 51 -
5
votes1
answer195
viewsWhat are the differences between the following Caps and when to use each one?
Casting [...] process where an object type is explicitly converted to another type, if conversion is allowed. Source: Stackoverflow in Portuguese Assuming the following situation: var i = 10 What…
-
5
votes2
answers459
viewsTernary Operator C#
I would like to add one more condition to my ternary operator. Is more than two conditions possible? Or is there another possibility? I need to enter the property Productocatalogodigital which is of…
-
5
votes2
answers1594
viewsXML serialization - NFC-e ide element
I am trying to serialize an XML of the electronic invoice, but when I arrived at the ide element where is an Array object I unpacked, as I receive the error "Undefined object reference to an…
-
5
votes2
answers203
viewsDocumentation on WPF with pure C# code
WPF is what’s "new" for development, not only desktop but also mobile. However, almost all material that is available on WPF is fully tied to the use of IDE and XAML. But XAML is an intermediate…
-
5
votes1
answer3181
viewsDecimal places c#
I have a variable of decimal type returning me the value 270.61864847349717630804948048 how do I return with only 3 houses after the comma, in case pass 270.618 only. Thanks in advance…
-
5
votes1
answer110
viewsAllow new conditions to be added without modifying code
I am manipulating a .txt and I have to exchange values like M31 for T90 for example. My code is like this at the moment: //Change machine tools for Sodick if (_strLinesFinal.Contains("M50")) { _OS =…
-
5
votes2
answers1906
viewsawait Task.Whenall how to run multiple processes?
I am trying to create several task (async) they will perform the following logic: Parse an Html based on a received url with Htmlagilitypack Return a product model after parse Insert the Product…
-
5
votes1
answer977
viewsDoubt on how to print datagridview in reportviewer
I need to print the data of a Datagridviewer, which is the products launched in the sale. What is the best way to print this information in the Report? I tried to use the Table component, but I…
-
5
votes2
answers690
viewsChange property of multiple Uttons simultaneously
Hello, I am developing a project of a dental clinic in c# in which uses several buttons inside a picturebox to select the teeth, so I decided to put several Buttons with certain opacity and the…
-
5
votes2
answers190
viewsSystem modularization
I’m developing a C# system with Winforms from Livestock Control to a farm, and will communicate with a scale to improve the weighing process. Some of the features are (Bill entry, vaccination,…