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
votes1
answer1022
viewsRecover last inserted id and selected stroke
I have the following situation: On the same form, I insert a student: SqlCommand inserirAluno = new SqlCommand("INSERT INTO ALUNOS (Nome, DataNascimento, CPF, Endereco, Bairro, " + "CEP, Cidade,…
-
2
votes1
answer469
viewsConvert an object that implements the interface into its own interface
I made the following code: using System; public class Program { public static void Main() { //Este método funciona Metodo(new ClasseTeste(){ Obj = new Registro(){ Nome = "Nome Teste"}}); //Este não…
-
2
votes2
answers64
viewsInherit comments from a virtual object
How can I inherit the comments within the tag <summary> of an object? I have the following class: class BASE { /// <summary> /// String de Conexão a base de dados. /// </summary>…
-
2
votes1
answer501
viewsBidirectional Communication - Send and Receive string value correctly
Follows code from server: int port = 11000/*PortGranter.GrantPort()*/; TcpSocketListener listener = new TcpSocketListener(); var tcs = new TaskCompletionSource<ITcpSocketClient>(); await…
-
2
votes1
answer56
viewsBi-Directional Communication - How to get status?
Library that I use: https://github.com/rdavisau/sockets-for-pcl Follows code: Server: static async Task Run() { var listenPort = 11000; var listener = new TcpSocketListener();…
-
2
votes1
answer771
viewsHow to Implement Automapper 6.2.2
I’m following a tutorial in which classes are configured as follows: A class called Automapperconfig: public class AutoMapperConfig { public static void RegisterMappings() { Mapper.Initialize(x…
-
2
votes1
answer328
viewsWeb API does not accept parameters in the constructor with Autofac
I created an API to query client, this is my configuration: public static class AutofacWebapiConfig { public static IContainer Container; public static void Initialize(HttpConfiguration config) {…
-
2
votes1
answer834
viewsAPI Web Post Returns Invalid Content Type
I am trying to send a POST request to a Web API. If I do it for Postman, it works: Now when I try to perform through the code, I get the following error: { "status": false, "message": "Content Type…
-
2
votes1
answer114
viewsDetermine the number of items in a list that are within the limits defined in another list
I have a ListBox that contains an undetermined value of values and I want to play those values to a List<> and from what I’ve researched, I’ve made it this far: var todosValores =…
-
2
votes2
answers130
viewsThe Binding inside a Compositecollection does not work
I am using a Combobox in a WPF application and when a function is activated, it loads a List<string> coming from a webservice to a property on the screen. My problem is that I can’t get…
-
2
votes1
answer55
viewsIs there a maximum amount of use of "using"?
My initial doubt was whether it was right to use using inside using, I was able to answer that question: It is correct to use a block using within another block using? But I kept asking myself, is…
-
2
votes1
answer857
viewsDoes not contain a Definition for 'Include' and the best Extension method Overload 'Queryableextensions.Include(Iqueryable, string)
Why does my code not recognize the method . Include("Category") in my Consoleapp? Where am I missing? Severity Code Description Project File Line Suppression State Error CS1929 'Ienumerable' does…
-
2
votes1
answer72
viewsIs it possible to obtain a parent attribute when the class defines the child attribute?
Assuming I have the following hierarchy: [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public class GrandpaAttribute : Attribute { public GrandpaAttribute() {}…
-
2
votes3
answers253
viewsSearch for word variations
I have a sentence that I need to check if it meets a rule but there may be variation in writing (accentuation, more or less spaces,...) Example: string fraseProcurada = "Cadastro de Usuários - SP";…
-
2
votes1
answer57
viewsOptimize sequence of if
I have the following structure and would like to optimize the code of the if, there are already several equal parts. So I made a foreach. But the variable of type Expandoobject, I do not know how to…
-
2
votes0
answers302
viewsHow to use credentials on an Httpwebrequest
I’m trying to capture an image from an IP camera. In the first model tested, it worked normally, since the model in test did not require credentials to return the images as a array de bytes because…
-
2
votes1
answer701
viewsConcatenate arrays accumulating content in C#
Gentlemen, the question is the programming language C #, my question is: how can I place all the items of array B within each item of array A and the result will be stored in array C. Thank you.…
c#asked 6 years, 6 months ago Cleber Pessoal 101 -
2
votes0
answers88
viewsIt’s not overwriting the value
I’m wanting the final calculation information to overwrite what is already saved in the Stock table, as it would be to do this, because Save, is overwriting correctly, I tried to apply in the…
-
2
votes1
answer1087
viewsHow to validate Combobox?
I have a Form registration in which you have some fields TextBox and ComboBox, I want my code to allow the user to register only when all fields are filled, but it is only validating TextBox, thus…
-
2
votes0
answers202
viewsCopy files without jamming the network
When I joined the company, it already had servers, a stable network and a system developed in Delphi and everything working in the most perfect order. Backup is manually performed every day on an…
c#asked 6 years, 5 months ago Rafael Arthur 89 -
2
votes0
answers31
viewsAutocomplete comJQuery querie Estruturada
I needed to do a query that worked as the following example: In the print you can see that by typing an item, returns structured by neighborhood and then city. I wanted to know how to do my query…
-
2
votes1
answer123
views -
2
votes1
answer1598
viewsRemote server returned an error: (400) Incorrect Request
I created two methods, one for authentication via A1 and A3 type certificate and one for sending an xml, both of which request a client’s Rest api. In the authentication method, I send my…
-
2
votes0
answers65
viewsUse of xrTableOfContents
In my application, I have 3 different files from XtraReport. That is, practically Gero 3 reports and put together all in one PDF. In the first XtraReport, have the component xrTableOfContents1 which…
-
2
votes1
answer189
viewsRuntime object example in C#
Reading an article appeared the following term Runtime Object or "runtime object". What would that object be? Would it be an instance of a class? Someone could pass some example? The part of the…
-
2
votes0
answers363
viewsInvalid parameter, Memorystream
Good afternoon guys, I’m developing a small project in c# that needs to present an image together with a recipe and it is the first time I work with image in database, I already inserted the image…
c#asked 6 years, 5 months ago Michele Santos 21 -
2
votes1
answer96
viewsWhite screen in transition between activities
I have a project in which I developed a method to save a reference to the activity current and when I used the HOME from the next screen, it returned to the activity using that saved reference. But…
-
2
votes1
answer98
viewsError creating an executable distribution with sql database using Entity Framework
I am developing a C# winforms desktop application in Visual Studio with Sql database through the Entity Framework. The intention is that it be a local database, the program will be installed on…
-
2
votes1
answer77
viewsIs it possible to insert parameters in Filters Attributes?
I use ASP.NET and to do the access control by level, I use a filter that checks the level of permission of the user and allows access to view. [HttpPost] [AutorizacaoFilterAttribute] //Esse filtro…
-
2
votes1
answer541
viewsStorage of List-like variables in an SQL-Server database
Good Evening Everyone, I am developing an application that makes a relationship between a Player and one or more games(online games), the problem is that a game can have one more different skills, I…
-
2
votes2
answers93
views -
2
votes2
answers621
viewsDo not let browser save password
I need to make the browser does not save the user password, I have tried autocomplete="off", autocomplete="new-password", already put in the form of the page autocomplete="off", but even so the…
-
2
votes1
answer198
viewsText-Align of a Label only
On a ". cshtml" web page I have several Abels declaring the class horizontal form and the class control-label. By default, these classes align right in my project, ie.. implement the property…
-
2
votes1
answer156
viewsWhy use readonly to instantiate?
I read and reread that question/answer a few times and I understood the difference between const and readonly. I also read the documentation, but I still can not understand what gain I have using…
-
2
votes0
answers15
viewsError when navigating between screens with Xamarin IOS
I’m having trouble calling a second Viewcontroller within the method Rowselected in a class that contains the interface Uitableviewsource, while making the flame even instantiating the…
-
2
votes2
answers896
viewsHow to make the questions random without repeating and run a specific number of questions?
I wanted to make the questions were random but not repeated running the 6 questions that make up each theme of my QUIZ-style game, if they know an easy method for my problem. I tried several…
-
2
votes3
answers258
viewsIs there a way to dynamically add attribute to instantiated object in C#?
Well, in C# we put attributes as follows: [Required("Este campo é obrigatório")] public string Nome {get; set;} What I would like to know is whether there is a way to add attributes dynamically to…
-
2
votes3
answers120
viewsProperty defined in constructor only returns zero value
I created a Web API in C# that returns me a list of products in JSON. However, the property PrecoVenda is always returned with the value zero and I noticed that this occurs because in the class…
-
2
votes2
answers1139
viewsGet Solution Folder C#
I have a solution with 4 projects inside. In my controller I need to open an HTML that is inside another project, but I can’t open the file folder. Below follows print with my structure: The class…
-
2
votes1
answer503
viewsData return Json
I have this function to return the data in JSON, but I’m not able to make it work in MVC Core. public ActionResult SalvarItens(string HoraInicio, string HoraFim, bool Seg, bool Ter, bool Qua, bool…
-
2
votes1
answer98
viewsSemaphoreslim locking method
I am using Semaphoreslim to make the "lock" of some methods of my Web-API, until it worked correctly but there are times when these same methods get totally stuck, by Postman when I run gets a…
-
2
votes2
answers179
viewsConsume Json and direct to a database using C#
I’m having trouble consuming a return json and convert it into object to then write in the database, my variables always return "null", I have tried several forms and always stay barred in this…
-
2
votes1
answer683
viewsButtons with WPF images
I’m new in WPF and I’m wanting to create a button, where its content will only have a background image and nothing else. Will not have border, background color or text, just a clickable image. I…
-
2
votes1
answer244
viewsPrivate class in C#
I have a class Pessoa.cs private, but I can call her in some other class, for example I created a class called Parametro.cs; I can instantiate the class private Pessoa without the slightest problem.…
-
2
votes2
answers965
viewsWCF ERROR: Failed to add a service. Service Metadata may not be accessible. Make sure your service is running and exposing Metadata
Well, this error is happening, after I did the procedure to access the IIS Remotely. Error: Cannot obtain Metadata from http://localhost:xxxx/Service.svc. If this is a Windows (R) Communication…
-
2
votes1
answer59
viewsHow to show in a query records that do not have a referenced datum
I have 3 tables: Person CREATE TABLE Pessoa ( ID_Pessoa INTEGER PRIMARY KEY IDENTITY (1,1), ID_Telefone INTEGER FOREIGN KEY REFERENCES Telefone (ID_Telefone), Nome_PSOA VARCHAR(50) NOT NULL,…
-
2
votes1
answer51
viewsC# - Name of the instance property in a Datagridview
I have a class Produtos with the following attributes: public class Produto { public int cod { get; set; } public string codBarras { get; set; } public string nome { get; set; } public Categoria…
-
2
votes1
answer466
viewsValidate empty fields in XLSX file - (Epplus) ASP.NET
I am importing an XLSX file into C#, using Excelpackage. I do some validations on import Ex: Numeric, text and if field is empty. Note: If all columns in my file are filled in the import is done…
-
2
votes1
answer827
viewsThe configuration section cannot contain a text or CDATA element
The error started to appear when I added the variable: <add key="Teste" value="true"/> Whole Config App.: <?xml version="1.0" encoding="utf-8"?> <configuration>…
-
2
votes1
answer1913
viewsThe name 'Component' does not exist in the current context
I’m trying to create a Component view to reuse on the pages, I’m trying to follow some video tutorials. I’ve installed via nuget the entire Microsoft.AspNetCore.Mvc, but when I try to call it from…