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
answers404
viewsPublication of ASP.NET MVC Project
Good morning gentlemen, I work in systems development, but until then I never had to publish on the internet an application of mine, because I have always worked with projects ready, what is the…
-
3
votes2
answers89
viewsTransforming bank information into Link
I’m making a site with a string from the database but I want this string to be informed as follows, in place of it will appear a button that the user will click and this button will open the url…
-
3
votes2
answers907
viewsUnexpected type when serializing web API
I am trying to use the Web Api and getting this error while trying to serialize an array. The 'HT.Data.Client' type with data contract name 'Client:http://schemas.datacontract.org/2004/07/HT.Data'…
-
3
votes1
answer65
viewsDoubt in a lambda expression returning "true"
When I do that: List<Tipo1> tipo = await context.MeuMetodo.Find(x => true).ToListAsync(); What am I saying here: (x => true)?
-
3
votes1
answer973
viewsError to leave application authenticated by Windows
I’m trying to leave an application authenticated by Windows. But when I change the settings on IIS with anonymous authentication disabled as per the image below: I have the following mistake:…
-
3
votes3
answers182
viewsLinq filttar elements of LEFT JOIN
I would like to return an object with your children, but I just wanted you to bring the children that corresponded to a certain condition. ex: I have the following classes: public class Fornecedor {…
-
3
votes1
answer1744
viewsHow to Validate Maskedtextbox?
I have a record field that mixes textbox common with maskedtextbox, created a validation code that does not allow the user to register if one of them is empty. But this only validates the textbox…
-
3
votes1
answer459
viewsExecute 2 querys or more
I wanted to execute 2 darlings in C# when the button is clicked, but I can only execute one. public static void excluireventos() { string connectionString = Conn.tank(); using (SqlConnection…
-
3
votes1
answer1159
viewsThere is no Viewdata item of type 'Ienumerable' that has the key
I’m having trouble with the Employee Position that is on a separate Table, when I try to create an employee selecting the position, he error... but if I assign the position in Controller (Ex:…
-
3
votes2
answers499
viewsDefine a generic variable without defining the type
I’m doing some tests on Unity so I can practice programming. I’m new and this question can be kind of stupid. I want to know if this is possible: I created the following abstract class: public…
-
3
votes1
answer107
viewsMethod with many if and Return
I think my code is too polluted with a lot of if. [ValidateModelAttribute] [HttpPut("{id}")] public IActionResult Put(int id, [FromBody]UserDto model) { try { if (model == null || model.Id != id)…
c#asked 7 years, 10 months ago Diego Zanardo 3,301 -
3
votes2
answers95
viewsLabel in loop on Foreach
I’m having difficulty showing information that comes from an object to display on a Label, returning in list form. //Pegando os dados do Rest e armazenando na variável usuários var usuario =…
-
3
votes1
answer191
viewsHow to show data from two tables in c#?
I built a webservice in c#. With a table it was easy to display but what if I have two tables how would it look for me to display this data? I did so it’s the easiest way: [WebMethod] public String…
-
3
votes2
answers72
viewsTextbox changes the value to decimal (EN) when pressing the TAB, however I want to leave currency (REAL) the field
I have a field <TextBox x:Name="TbTotalICMS" Style="{StaticResource MeuTextBoxValor}" Text="{Binding Vicms}" /> My Vicms is a decimal. By pressing the TAB key, the value that is 1.00 (example)…
-
3
votes1
answer335
viewsWPF Xaml Stringformat
Good afternoon guys, I’m having a problem kind of ridiculous, but I can’t find the solution. I’m trying some stringFormat as StringFormat={}{0:#,#.00}} and StringFormat=N2}, besides…
-
3
votes1
answer132
viewsHow to simplify declaration of types with Entity Frameowrk?
I have some tables with several fields of type datetime, and for all of them I need to create a validation in Onmodelcreating() for this type, IE, I need to define .HasColumnType("datetime");, my…
-
3
votes1
answer325
viewsHow to call a View by passing parameters through json
I have this code that passes parameters to my controller: var id = $(Musico).val(); var url = '@Url.Action("Votar","Chamada")'; var tipo = 1; $.ajax({ url: url, data: { id:id, tipo:tipo } }); my…
-
3
votes2
answers540
viewsHow to sort with LINQ with one LIST<T> inside another?
Apparently easy but I’m not able to make a LINQ that orders two LIST that are nested. I don’t know if the word "nested" is correct. How can I do this ordering through LINQ, in the code below I…
-
3
votes1
answer108
viewsSearch for missing record range
Imagine the following situation: a table looks like this: Id (int) - Codigo (int) - Descricao (varchar) 1 - 01 - Descrição 1 2 - 03 - Descrição 2 3 - 04 - Descrição 3 4 - 05 - Descrição 4 Note that…
-
3
votes2
answers6439
viewsSerializing and Deserializing Json objects with C#
Consider the JSON below { "atividade_principal": [ { "text": "Atividades de televisão aberta", "code": "60.21-7-00" } ], "data_situacao": "03/11/2005", "nome": "GLOBO COMUNICACAO E PARTICIPACOES…
-
3
votes2
answers510
viewsCreate class instance in threads
Imagine I have a class: Class Animal { //Propriedades } Now creating multiple instances of the class I do as follows: Animal[] animais = new Animal[10]; for(int i = 0; i < 10; i++) { animais[i] =…
-
3
votes1
answer615
viewsError creating Xamarin cross Plataform project in Visual Studio. "The project requires a Platform SDK (UAP, version=10.0.10.586.0)"
When trying to create a project Cross Platform App with the template Master Detail I get this mistake: The SDK he claims to be absent is installed. I’ve reinstalled it several times. When I try to…
-
3
votes2
answers206
viewsWhere to place the View Model rule
I need to create a View Model to use on the screen. I’m wondering where to put the button rule be enabled or not. I thought about this implementation, I would like to know if it is the best way.…
-
3
votes1
answer868
viewsError 400 when sending request to Esocial (C#)
I am receiving error 400 when executing SOAP request on eSocial servers as a response. The error occurs in this command: using (HttpWebResponse resposta = request.GetResponse() as HttpWebResponse) I…
-
3
votes1
answer143
viewsc# Microsoft Access converting data
I am having problems with INSERT and UPDATE because on my machine the dates are being converted automatically, but on users' machines not. Ex: OleDbCommand cmd = new OleDbCommand("UPDATE…
-
3
votes1
answer1541
viewsError: unrecognised exhaust sequence [C#]
For this code snippet in my program I receive the error warning that it considers that the command has an invalid exhaust sequence, that is, not recognized. string.Format("/c {0}", "cd .\Debug &…
-
3
votes1
answer253
viewsUsing Access to export in Excel, Parameterized Query
I am using the database Access, need to export a query to excel. My problem is this:: I am using a parameterized query in Access for the access itself to export to excel. When I make the export…
-
3
votes1
answer186
viewsTrying to pass Controller values to Global.asax.Cs to fill sessions
When I try to pass some value from my controller to the Global.asax the values received in the aggregate are always zero. Controller: public class LoginController : Controller { DataContext db = new…
-
3
votes2
answers174
viewsUse of LINQ to query a collection
about min: I come from JAVA and recently I am learning c#, but I have a doubt about the use of LINQ. Many tutorials speak of the wonder that is LINQ but I so far can not understand its usefulness.…
-
3
votes2
answers1435
viewsSQL query taking too long and returning a Time Out error
I am trying to perform a query in SQL. Below is the method: public void excluirVenda(int Codigo) { Conexao conexao = new Conexao(); SqlCommand cmd = conexao.CreateCommand(); SqlTransaction…
-
3
votes1
answer32
viewsMigration Conventions
I have an MVC DDD application that uses Sqlserver. I’m trying to get the database to Postgressql, but there is a FK duplicity error. For example, the default Sqlserver would be generated:…
-
3
votes2
answers5175
viewsCopy a List to another List without dependencies
How do I copy data from one list to another in a way that is independent of each other? I have a list<> of a class I created where the data inserted in it, appear in a listbox, and I wanted to…
-
3
votes1
answer1403
viewsDecimal values being rounded in Sqlite
After migrating my database from Access to Sqlite 3 in a Windows Forms application, I have been having difficulties with Decimal values. If I run a simple select: SELECT * FROM Item WHERE id = 1;…
-
3
votes1
answer73
viewsError passing grid view parameters of a form in combo box
Good morning, I have a form where I consult my budgets and in it I own a grid view. When I double-click on the grid line it opens another form. But I do not see the data that is in the line of my…
-
3
votes0
answers138
viewsJava equivalent C# encryption
I have the method below in C# and I need to do something equivalent in JAVA, but I’m not getting it. Could you help me? private const string chave = "eMbARaLhaDo"; public static string…
-
3
votes1
answer475
viewsUsing dependency injection outside a controller with ninject
I have following code: public class ContaController : ApiController { private readonly IAppServiceUsuario _app; public ContaController(IAppServiceUsuario _app) { this._app = _app; } } how to inject…
-
3
votes2
answers802
viewsCommand button does not work within Listview Xamarin Forms MVVM
I’m trying to create a button with the event Command within a Listview on MVVM, but is not falling in the event ViewModel. How do I get this button Command access your method on ViewModel ? And…
-
3
votes1
answer140
viewshow to change the material of an onclick object
I am using unity3d, I have a Prefab of a sphere and another of a cube, with a simple material and I would like to know how I can change the material of these objects by clicking a button on UI.…
-
3
votes2
answers120
viewsEnumeration class in the Repository Pattern
How can I read from my bank an attribute int which in my system is a type attribute Enumeration in the Repository Pattern? I took a class: public class Status : Enumeration { public static readonly…
-
3
votes2
answers227
viewsChanging opacity of one form through another
I need to change the opacity of the main form every time the user clicks on the close button. When he clicks on this button the opacity is in this.Opacity = .75; and opens a new form asking if he…
-
3
votes0
answers730
viewsHttpwebrequest - Recover Nfe
I’m accessing the link of the Farm site ( http://www.nfe.fazenda.gov.br/portal/consulta.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8%3d) with the aim of returning the filled Nfe. When I…
-
3
votes1
answer114
viewsIs it a problem with my architecture?
I’ve been a software developer for a long time, but I’m always looking to learn "different ways of doing things". I am currently working on a new project and decided to base the architecture on…
-
3
votes1
answer928
viewsHow to save an XLSX (Excel) file instead of CSV?
Today I have the code below, which saves a file in CSV format. What I need to change to save in XLSX format (Excel)? public static void buildCSV(string filename = "resultado.xlsx") {…
-
3
votes1
answer4168
viewsHow to create a variable accessible in all Forms?
In my application you will have a login system. I want to create a variable to store the user id that is logged in, and that it can be accessed in all other forms. I need this because in my…
-
3
votes1
answer763
viewsHow to Save Files to Separate Server by Extension
I have a WEB API who receives a file via POST follows the code of Controller: public async Task<HttpResponseMessage> Post() { // Ver se POST é MultiPart? if…
-
3
votes1
answer385
viewsSelf Relationship with Entity Framework 2.2
How to Make a Self Relationship with EF Core 2.2? I found a link that teaches to do with EF, but in EF does not have the Withoptional method. public class Menu { public int Id { get; set; } public…
-
3
votes3
answers96
viewsLink selection between two Listviews
It would be possible to link the single selection between two objects ListView via Xaml? For example, I have two ListView, the TopListView and the BottomListView, both configured for simple…
-
3
votes1
answer501
viewsFill in date and time in View mvc 5 Razor
I have a registration form where I have a record date field that I currently fill in my save method, only that my server is hosted in another country where the field is being filled in from the…
javascript c# entity-framework asp.net-mvc-5 asp.net-web-apiasked 5 years, 9 months ago Thiago Ubiratan 353 -
3
votes1
answer431
views -
3
votes1
answer838
viewsSpeech Recognition does not work
Why the Speech Recognition does not work on Windows 7 or Windows 10. I developed by Microsoft sample code and it didn’t work, I found this code on the internet that shows it working on the person’s…