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
-
2
votes3
answers40
viewsSystem.Nullreferenceexception in an attribute of type Stringbuilder
Why error occurs? How to fix? Model: public class modelExemplo { public StringBuilder listNewsletter { get; set; } } Controller: public ActionResult funcaodeteste() { modelExemplo obj = new…
-
2
votes1
answer98
viewsASP.NET C# Listview Itemcommand is not working
Man ItemCommand of ListView does not work. Can anyone point me out if there is something missing or errors in the code? <!-- Primeira Coluna --> <div id="firstCollumn"> </div>…
-
2
votes1
answer487
viewsHow to create master-detail form using a Viewmodel
I have a viewmodel in my project. Within it I have two entities that are a list of items. I’m doing the data editing logic of these entities that are inside the viewmodel. I have 5 entities in all.…
-
2
votes1
answer894
viewsTryparse error of Datetime converting string in Double format
I have a method of using the DateTime.TryParse to convert a string for the guy DateTime, but lately I’ve realized that string format Double would also be being converted to date. Is there any…
-
2
votes1
answer168
viewsLinq command to bring up a decimal query C#
I’m having trouble understanding how to bring a query from textbox of a column where the field is decimal? if (txtNomePesquisar.Text.Equals("")) { MessageBox.Show("O que você procura? "); } else {…
-
2
votes1
answer45
viewsUnityengine.Debug error:Log(Object)
Personal my app is ready and when I compile it, it getting this error: Unityengine.Debug:Log(Object) How do I stop receiving this error? Don’t compile, it stops at this. Does anyone know why he…
-
2
votes2
answers718
viewsForm behind the Windows bar
What is happening and the following, when I set the form in c# visual studio 2015 to maximized, the bottom of the form is behind the windows taskbar, how can I solve the problem. Follows the code:…
-
2
votes1
answer40
viewsC# All my combobox are changing text
I’m having a problem with my program where when I change the values of one of my combobox, example: private void Ex1Mat_SelectedIndexChanged(object sender, EventArgs e) { if (start == false) {…
-
2
votes1
answer210
viewsGet part of a string with Regular Expression - C#
Based on the string "Plan Liberty Company +50 - 043-98965-2784(058/POST/SMP)", I need to get the part of "043-98965-2784". I realized that in the txt file I’m using, the numbers follow the pattern…
-
2
votes1
answer44
viewsConsole write 2 strings from the list
I created a list in which I added 2 strings: var lista = new List<string> {cliente.Nome, cliente.Sobrenome}; And in the end I wanted you to show it like this: Console.WriteLine(lista[0]); But…
-
2
votes2
answers1618
views -
2
votes0
answers668
viewsError while updating Mysql.Data
I upgraded Mysql.Data and Mysql.Data.Entity from version 6.9.9 to version 6.10.4 and started getting the error below : Inheritance security rules were breached by the type:…
-
2
votes2
answers59
viewsTaskcompletionsource<Tresult> without a type parameter
The class TaskCompletionSource<TResult> needs a type TResult. That way, when I need to use this class without having a return type (void), I have to do something like: var tcs = new…
-
2
votes2
answers3424
viewsHow to clean Listbox
How to clean a ListBox? I did it this way but it didn’t work: private void LimparListBox() { //lbxResumo.Text = ""; lbxResumo.ClearSelected(); } private void btnLimparList_Click(object sender,…
-
2
votes1
answer4637
viewsAccessing files in C: error: Access to path (...) has been denied
I am making a program in C#, which needs to access all files and folders from the computer. It turns out that when I go to access a folder or file near C:\, he says this message: Access to path 'C:…
-
2
votes1
answer362
viewsHow to configure Automapper in a Windowsform project?
How do I set up Automapper in a Windows Forms app, being: Which file and should I configure to load together with the application and make it available? How to use with a simple example?…
-
2
votes1
answer56
viewsWhen you get to 12:00 every day write on the console
How do I make sure that when the time on my computer reaches 12:00 it writes on the console "Hello World" every day?
c#asked 6 years, 11 months ago user92401 -
2
votes1
answer3789
viewsC# Digital Certificate A3 CPF Token
I have to put a digital certificate type CPF A3 token with password, in an Httpwebrequest, so I was trying to use the X509certificate2, as follows: private X509Certificate2 GetCert(string CertFile,…
-
2
votes2
answers135
viewsHow to capture information from a 64-bit process that is running?
Well, I need help to capture the information of a running process. I can accomplish this task by accessing the mainmodule 32-bit processes, however, I cannot do the same with 64-bit processes. I…
-
2
votes1
answer135
viewsLog4net stopped showing logs
My console stopped showing the logs from nowhere, I have compiled several times and never happened this, only now Code: public static readonly ILog log =…
c#asked 6 years, 10 months ago user92401 -
2
votes1
answer119
viewsHow to get the content of a tag from a Linq query?
I have XML with the following structure: <?xml version="1.0" encoding="UTF-8"?> <pessoas> <pessoa> <nome>Joao</nome> <email>[email protected]</email>…
-
2
votes1
answer89
viewsIn a MVC 4 C# Web Application model, in which layer can the ADO.NET Entity Data Model file be located?
What layer do I put him in? Model control or view? ADO.NET Entity Data Model what makes the connection to the database.
-
2
votes1
answer1701
viewsC# - Use of A3 Certificate (Card Reader) + Windows Service
Good morning to all. I created a windows service (C#) where I sign XML from NFC-es using Flexdocs DLL. Using A1 certificate everything works normally, but when using A3, the frame where I must enter…
-
2
votes1
answer576
viewsLoad image from project
I have a project developed from a console application in Visual C#, in which sends emails, the text being in html format. Today I put an image inside that html the following way: "<img src='" +…
-
2
votes0
answers72
viewsUpload files. only in Xamarin Android
I’m trying to convert a class Java for C# in the Xamarin.Android. The class Java that’s the one: private native boolean OpenDeviceCtx(Object obj); public native boolean CloseDevice(); public native…
-
2
votes1
answer52
viewsHow is the encryption of a Securestring made and stored?
The class SecureString is used to represent a text that must be kept confidential in memory (passwords, card numbers, balances, etc.), and carries out its correct deletion from memory when said text…
-
2
votes1
answer407
viewsSolution . Net with Membership does not connect to oracle base
I am trying to run a project on my computer but it accuses error in string: Oracleconnection.Connectionstring is invalid The same project works normally on the computer where it was started. The…
-
2
votes1
answer74
viewsLogin Beanstalk API
I’m trying to make an integration with the service of http://api.beanstalkapp.com/ and I’m having trouble making the request in C#, always returns me the error below: An Exception of type…
-
2
votes1
answer1099
viewsRestrict access to the Web API
I have a Web API where I restrict access to your methods through the EnableCors, indicating the URL I want to give permission, as follows: namespace WebService.Controllers { [EnableCors(origins:…
-
2
votes1
answer130
viewsProblem with Bundle on the server
Good morning, I was implementing the use of Bundle in my ASP.NET MVC project, in the development environment worked perfectly. But when I go up on the server it does not work. I went to debug in the…
-
2
votes1
answer439
viewsWrite Json Return to txt c#
I am trying to record a return of a JSON in a txt file. But when I try to use DeserializeObject makes a mistake. I have the Json below (example of 2 records): [ { "TipoVeiculo": "Caminhão",…
-
2
votes2
answers2666
viewsPass values from one Object to another form C#
I have a system, where after the user logs in, I pull a lot of XML data on it and save it in attributes of an object, but there is another form to make the password change ,where I need the User_id…
c#asked 6 years, 10 months ago Gabriel Longatti 559 -
2
votes2
answers912
viewsReading user information
I started studying C#, and my first program (except for hello world hahahaha) is an area calculator. In the code below, after I enter the option (choosing which figure I want) the console simply…
-
2
votes1
answer47
viewsHow can I dynamically set an avatar photo in windows Forms?
I have the following line of code that will set the client image on the screen if there is, if not will leave as null. How can I leave dynamic, IE, if the customer does not have the photo will set…
c#asked 6 years, 10 months ago Igor Carreiro 1,917 -
2
votes2
answers44
viewsWhy is Directoryinfo.Exists true after deleting the directory?
In the following code var Directory_02 = "TEST_01"; DirectoryInfo directory2 = new DirectoryInfo(Directory_02); directory2.Create(); if (directory2.Exists) { System.Console.WriteLine("{0} exists:…
c#asked 6 years, 10 months ago Diego Moura 118 -
2
votes2
answers303
viewsquery and change procedures for DAO C#layer
inclusion, alteration, achievement Various procedures have been created for inclusion, amendment, consultation, data collection, etc. The procedures were created in SQL Server 2014. I need to access…
c#asked 8 years, 2 months ago Mariana de Amorim Delfino 119 -
2
votes1
answer328
viewsHow to show a Messagebox when selecting an item in the combobox
I would like to know how to implement in my combobox one Messagebox when selecting an item from the list? Example: Combo list: Junior Maria Joseph When selecting Maria, a message box appears…
-
2
votes2
answers155
viewsConvert date 20171130 to format 30/11/2017 in string
I have this date field '20171130' saved in the database, and I need to convert to string formatting "30/11/2017" in my application, how to do this type of conversion ?.
-
2
votes1
answer579
viewsHow to store passwords in environment variables (and remove them from version control)?
I’m migrating from a local tfs to a private git (probably bitbucket). Today I simply encrypt webconfig, now I will have to take my sensitive data out of version control (Connection string,…
-
2
votes1
answer925
viewsDate-place on @Html.Editorfor
I have a model property that I will keep DateTime: [DataType(DataType.DateTime)] [DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "{0:yyyy-MM-ddThh:mm:ssZ}")] public DateTime…
-
2
votes1
answer271
viewsUsing TLS 1.2 in . NET Framework 2.0
I’m looking to use TLS 1.2 on a call Webclient in the framework .NET 2.0 It is possible? try { using (System.Net.WebClient client = new System.Net.WebClient()) { string u = client.UploadString(url,…
-
2
votes2
answers164
viewsHelp with textbox validation
Guys good afternoon. I’m having difficulty performing a task, which is as follows:: I have a customer registration, that when the user edits something from the register, when saving is presented a…
-
2
votes1
answer38
viewsVisual Studio Error 2015 Update 3 cannot remove breakpoint
In my project I have a solid breakpoint in Visual Studio that I can’t remove. I can add other breakpoints. Some removed, but some not. Does anyone know how to fix this?…
-
2
votes2
answers223
views@Html.Checkboxfor Works on GET, but not on POST
I have the following model: public class MEUViewModel { public List<Obj1> Obj1s { get; set; } public List<Obj2> Obj2s { get; set; } public int IDMeu { get; set; } public int IDMeu2 {…
-
2
votes1
answer4309
viewsSubtract date from datetime
I need to take current date and subtract 3 months. Bang making conversions and subtracting 3 but will go wrong to turn the year, in January for example will result in month -2. I believe that there…
-
2
votes1
answer333
viewsHow to set position of objects in form in full screen
how to define where each component of my form is when it is in full screen. (When you make the form it stays in one way, when you run the form it stays in full screen (as I put) but the components…
c#asked 6 years, 10 months ago Rodrigo Gabriel 45 -
2
votes4
answers2882
viewsHow to extract data from an SQL query in C#
I’m not long in developing in C#, so I’m still learning... How do I extract the data from the query result made in the database? public static DataTable ConsultaCidade() { DataTable pDados =…
-
2
votes1
answer2046
viewsDecrypt MD5
I need to change this code to decrypt the data with it encrypted: public static string MD5HashCrypt(string text) { MD5 md5 = new MD5CryptoServiceProvider(); //compute hash from the bytes of text…
-
2
votes1
answer226
viewsMVC - Store user permissions in session using NLB - Network Load Balancing
We are developing an application (intranet) in MVC 4 where authentication is performed through Windows Authentication. When the user enters the application, a call is made to a service that controls…
-
2
votes1
answer211
viewsHow many threads should I split a task into?
I am developing an application in C#, one of my functions can be run with multiple threads. However, how many should I use? If the processor has 4 cores, there is advantage in using more than 4…