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
votes1
answer141
viewsParent form superimposing child form C#
I’m developing a Windows Forms application in Visual Studio and I’m having a hard time. I put the parent form to Ismdicontainer and instead of adding Toolbox, I made a form only with buttons, it…
-
3
votes1
answer248
viewsRecord Email and Phone Array in Database with Entity
I need to save an html array of telefones and Emails, in the database, but I’m not sure how to receive such data. Phone and email number can be 0 ou N, as in the image below, one can add as many…
c# asp.net-mvc-5 asp.net-core entity-framework-core .net-coreasked 5 years, 5 months ago Matheus 616 -
3
votes1
answer79
viewsDoubt about how to register
Good afternoon guys, good I’m new here, so I apologize for anything! My question is: I have an equipment table, a software table and an associative equipment-software. The ratio was (Equipment) 1 N…
-
3
votes1
answer285
viewsOpacity of images C#
Good morning, I came across a problem in my application Windows Form C#, I’m trying to apply an image with low opacity() background to my panel1, but the image when inserted gets 100% opacity,…
-
3
votes2
answers88
viewsAssign once control event to event method
I’m making a sequence of screens in the form, I have a main screen that loads other screens, the main screen is the Form1, and the subtleties will be the ones I will add on the main screen through…
-
3
votes1
answer94
viewsGrouping of values
I have an application that generates the following results: I would like to know how I can arrange the object in only 1 line, say have only one date, and within the date have the schedules, to have…
-
3
votes1
answer62
viewsDoubt with Viewdata using Asp.net core 2
I made an example for testing using Viewdata, apparently it should work, but it is generating me a reference error, as message below. The type or namespace name 'Student' could not be found I made a…
-
3
votes1
answer755
viewsGet path of valid files with regular expression
Context: I am monitoring file deletion and inclusion actions in a folder through Class FileSystemWatcher with the intention of registering a Log of the actions performed in it. Problem: This folder…
-
3
votes1
answer131
viewsAspnet Core API with Entityframework Core - Disconnected Entiades
My scenario is the following: I have an Aspnet core API that uses Entityframework for data access (postgree database). When I receive content in Json by the API (Put) and need to update the template…
-
3
votes1
answer82
viewsMake if in an HTML tag to add or not attribute "checked"
I’m developing with the .Net Core Razor and I’m setting a string in my GET and I need that, according to what this string (in the case of "true" or "false"), checkbox whether or not marked. To…
-
3
votes2
answers333
viewsOpen page in modal form
I’m doing a crud and would like to open another page in modal form, but do not know how to do this, I even found on a site explaining how to do with javascript but when clicking the button nothing…
-
3
votes2
answers560
viewsHow to improve the performance of the Linq query?
I have the consultation below var f = (from l in fpcList join fpp in FPP on new { l.fpId, l.etId } equals new { fpp.fpId, fpp.etId } join fpcp in FPCP on fpp.fppId equals fpcp.fppId select new {…
-
3
votes1
answer55
viewsHow to cover using Mock and C#?
I need to cover for the method example below: public int GetQtdCart() { int qtCart = 0; using (var db = new SfrEntities()) { qtCarteira = db.Set<Contract>().Select(x =>…
-
3
votes1
answer83
viewsCounting amount of results of a Split()
I have a string that looks like this: Yeah, No, Maybe And I have a code that I need to put these string results separately into a <option> of a <select>. I intend to do this through a…
-
3
votes0
answers88
viewsC# EF Core - simultaneous conflict with Trigger mariadb
I’m using EF Core with mariadb, in the database I have fields with defined default values and a trigger "before insert". In fluent mapping, I report the default values to the field normally.…
-
3
votes1
answer454
viewsQuestions about Sendmessage and Postmessage
I began to study the methods of SendMessage and PostMessage of User32.dll and I came up with some questions. I will put down the code I tested and soon after the questions, if anyone can help me.…
-
3
votes2
answers134
viewsEF Core - Pass parameter with integer list
I am trying to execute a query by passing as clause an 'in' with integers, this is the code so far: public List<Pedido> GetByUsuario(List<GestorVendedor> gestorVendedor) { int[]…
-
3
votes1
answer291
viewsIgnore Automapper property
I’m using Automapper version 7. I need to ignore a property that is in the result class and has no source class. As below. public class Contrato { public string Id{get;set;} public string Nome…
-
3
votes1
answer176
viewsPass parameters with properties c#
I’m putting together a script of fighters, the category I want to be a private method and that it is according to the weight that the user type, but I’m not able to mix these two attributes in the…
-
3
votes1
answer549
viewsCS7036 error on C# calling a function
I just got into the matter of functions and methods and I’ve come across a problem that I can’t solve at all because I don’t understand why. The point is: "Create a method that takes an integer…
-
3
votes0
answers493
viewsDigital signature with C# and Json
Good afternoon to you all. I’m using the link code https://github.com/Gread/BoletoOnlineBradesco that uses C# to sign Json and send the letters to Bradesco. My problem is occurring in Bouncy…
-
3
votes2
answers621
viewsHow to use Enum.Parse()?
My code displays error when using Enum.Parse<enum>(Console.ReadLine()); I am asking the user to enter the level of the position occupied, however to receive the data entered by the user…
-
3
votes1
answer46
viewsDeserialize JSON with Newtonsoft JSON
I am trying to make an deserialize, to create a list with the contents of this JSON. However, everything arrives to the list as null. I’m gonna let down what I’ve got so far. I have the following…
-
3
votes0
answers26
viewsHow to check all Checkboxs on my Grid? Not just the first pagination
var grid = new WebGrid( canPage: true, rowsPerPage: 10, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridViewCV", ajaxUpdateCallback: "ajaxWebGrid"); var columns = new…
-
3
votes0
answers111
viewsWhat does "out" do in C# and what is the difference of the pointer?
I was playing Space Engineers and it is possible to add custom codes, called in-game script, in C#. Finally, I came across the need to use such a out, but I didn’t understand what he does and why he…
-
3
votes1
answer30
viewsHow to join sublists with Linq
Imagine I have the following classes: public class Pedido { public int PedidoId { get; set; } public List<ItemPedido> Itens { get; set; } } public class ItemPedido { public int ItemPedidoId {…
-
3
votes2
answers145
viewscheckar checkbox of gridview based on database value
My application needs to release types of accesses, for example, we have 5 branches and such person needs to access content from only 3 branches. The ADM user, can create or edit new users. When…
-
3
votes2
answers295
viewsProper use of while to validate data entry
I’m trying to apply a repetition using the while also using the IF condition, which returns a message to the user if they enter an invalid value. Note that I write nothing inside the while, but the…
-
3
votes1
answer218
viewsProcess.start does not open osk.exe in C#
I’m using the Process.start() to open some system applications, however despite working properly for the notepad and for the calculator, when I try to open the screen keyboard (osk.exe) the program…
-
3
votes1
answer167
viewsCapture and treatment of exceptions in a generic way
In general the most common is to capture the exceptions specific and do some treatment with it, right? Example: try { //Algum trecho de código } catch (MyException myException) { //Especifico para…
-
3
votes3
answers125
viewsSave or remove accent on a Textareafor
Hello. I have a Textareafor which receives the HTML content, however when saving the data, the accents and special characters are encoded and I have problems later when editing or viewing the data.…
-
3
votes2
answers146
viewsError concatenating string from path
In this program right at the beginning has a function that creates a folder in the user’s documents to save some information Giving a research I came to the conclusion that it should stay like this:…
-
3
votes2
answers164
viewsUpcasting and subsequent downcasting allows you to access the attribute of the original type?
When I make a upcasting, object 1 will be converted to its supertype and an object 2 is created When object 1 is instantiated before doing the upcasting, has attributes that do not exist in the…
-
3
votes1
answer91
viewsHow to deal with business rules?
I am working on a C# WPF + EF6 application and find myself lost when it comes to reusing business rules. I’m using the standard repository + Unit of work, but I believe that copying-pasting complex…
-
3
votes1
answer101
viewsImprove performance in iteration
I have a C# method that receives a List<string> and I must return a string with the list of members of the List<string> ordered by number of occurrences and then alphabetically. I did…
-
3
votes1
answer35
viewsHow to serialize Object for yaml in . NET?
We can serialize objects (I’ll use as an example C#) for XML, using the class System.Xml.Serialization.XmlSerializer, for example: var obj = new AlgumaClasse();…
-
3
votes1
answer61
viewsHow to fill empty space on the Grid with Textblock?
I have the following XAML <Window x:Class="ambiente_teste.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"…
-
3
votes1
answer64
viewsWhat is the access modifier of an explicit implementation?
I created an iterator class that implements the interface IEnumerable<T>, implementing the interface IEnumerable. To make the implementation correctly, it is necessary to explicitly implement…
-
3
votes1
answer48
viewsUnable to initialize a generic object with inheritance
I’m having a hard time accepting an inherited class as a generic class type. public class Teste { private void Testando() { var dog = new Cachorro(); dog.Nome = "Toy"; dog.Patas = 4;…
-
3
votes1
answer81
viewsIs it correct to use an object to call a method where it will be the parameter?
I am creating a small project in without Entity Framework and I have a question at the time of passing an object as parameter, it is correct to pass the same object that calls the method as…
-
2
votes1
answer672
viewsHow do I make Html.Labelfor() display an asterisk in required fields?
I want the required fields (properties with the attribute Required) render with an asterisk indicating that it is a required field. public class Foo { [Required] public string Name { get; set; } }…
-
2
votes1
answer324
viewsHow do I get access_token when I log in with Facebook on MVC5?
When I create a project MVC5 the Visual Studio automatically creates a website for me with option to login by Facebook, Google... Just need to enable in the file "Startup.Auth.cs". But he does the…
-
2
votes1
answer1256
viewsHow can I run Javascript (most current possible) in C#?
First I tried to run with a control WebBrowser WebBrowser webBrowser1 = new WebBrowser(); webBrowser1.Visible = false; webBrowser1.Navigate("about:blank");…
-
2
votes1
answer954
viewsHow do I convert a Datatable to a dynamic object?
How can I convert a DataTable in a IEnumerable<dynamicObject>? For example, I want to convert any DataTable ID | Name DI | emaN --------- ou --------- 1 | x 2 | x 2 | y 1 | y In a list of…
-
2
votes2
answers3614
viewsHow do I convert the size of a file into bytes for KB, MB, GB, TB, etc?
I’m picking up the file size to display on the screen: new FileInfo(arquivo).Length Only this property returns me the total of bytes... I would like to display in a format that I could understand,…
-
2
votes1
answer1464
viewsSend CR LF via Serial port c#
I’m communicating by Serial (SerialPort) with a device that requires me to send commands CR LF at the end of each instruction for the device to understand that an instruction has been sent to it.…
-
2
votes3
answers2183
viewsHow to create a musical "player" in C#?
I’m creating a C#music player. The design part (sliders, volume bar, etc.) is all created, but the code is missing! How can I make the music system so that when I click on play he performs the…
c#asked 10 years, 8 months ago Mateus Otto 143 -
2
votes6
answers6049
viewsHow to make a textbox that updates every time you change the content?
How do you make a textBox that updates in the database the values that are placed in it? That is, the textBox is filled in and the user decides to change what is there and wants it to trigger*…
-
2
votes3
answers10204
viewsHow to put a value that is saved in the database in a combobox?
I am using C# Windows Forms with . NET 3.5. I’ve inserted all Federation states into the property items of my combobox. When I search for a record saved from my comic book, the combobox does not…
-
2
votes1
answer2484
viewsHow to create a dynamic Gridview?
Someone already created a GridView where there are already rows filled with values and in the last column of each row there is a LinkButton "Repeat" and when this LinkButton is clicked, repeats the…