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
-
4
votes1
answer80
viewsFormat the Array view in C#?
I have a string array. string[] nomes = { "Maria", "João", "Francisco", "José", "Antonio", "Osvaldo", "Francimar", "Cirineu" }; I would like to display them exactly like this on the Console Maria…
-
4
votes1
answer44
viewsIs it possible to restrict who can use the public classes of an Assembly?
The scenario is as follows: I have a AssemblyProtegido.dll written in . NET that contains public classes. I wish only specific assemblies could consume such classes. Assemplyprotegido.csproj public…
-
4
votes1
answer78
viewsHow to make Selectlistitem substring?
Follows the code: View: @model IEnumerable<Projeto.Models.Model> <table class="table table-striped"> <thead> <tr> <th> @Html.DisplayNameFor(model => model.Id)…
-
4
votes1
answer549
viewsDisable IIS cache
I’m having problems with IIS cache (I think the problem is he), whenever I make any changes in the database, changes do not happen on the website, keeps the old data. Changes only appear when I turn…
-
4
votes2
answers638
viewsInsert checkbox dynamically by returning Json does not display Text?
I’m creating a list of Checkbox according to the selection of a Select on the same screen. No event change of select is called via ajax javascript, the method that returns a Json with list(value,…
-
4
votes1
answer424
viewsTwo classes mapping the same table with the Entity Framework
I’m trying to do the entity map two classes to the same table this is possible? Setting: Man identity this decoupled (Eduardo Pires' Master) from my domain and the presentation layer in the domain…
-
4
votes1
answer241
viewsWhat is the advantage of using the latest version of . NET Framework?
By default my Visual Studio selects . NET Framework 4.6.1 when starting a new project, but is there any advantage in selecting the latest version? (4.7.1)
-
4
votes1
answer903
viewsC# Read Excel Spreadsheet
Hello, I have 1 problem reading an excel spreadsheet, ListaNomes.Add(new Entidades() { GrupoFornecParceiro = rd["Grupo do Fornec./Parceiro+"].ToString() }); when it goes to Add the value of the…
-
4
votes1
answer2184
viewsConvert a 'System.Collections.Generic.List' object to 'System.Data.Dataset'?
Cannot convert an object of type 'System.Collections.Generic.List in type 'System.Data.Dataset'? After making a report query, I am storing the data in a list and showing the data on the screen, the…
-
4
votes1
answer274
viewsError in Dapper query
Well, I’m trying to perform a consultation on Dapper and get the following error: The model item inserted in the dictionary is of type'System.Collections.Generic.List`1[Taxability…
-
4
votes3
answers103
viewsNullable property in C#
I was looking at some tutorials and suddenly I saw this property public Nullable<int> Id {get; set;}. What it means and when I would use it?
-
4
votes1
answer155
viewsHow to stop the SQL Server service using C#
I wonder if it is possible to stop SQL Server using C lines of code#. I have a C# application and would like to add a button to stop the SQL service or the instance, so I can work with the files.…
-
4
votes2
answers419
viewsGlobal variables Xamarin
Is it possible for me to create modules to add global variables in Xamarin? how I could create variables that can be accessed from anywhere?
-
4
votes2
answers220
viewsHow to map and obtain only one property or field of a query?
I’m using the Dapper that has the purpose of map properties of objects. See a practical example: var servico = conexao.Query<Servico>(statement.ToSql(), new { IdServico = id }).First(); That…
-
4
votes1
answer40
viewsHow to rollback the transaction using?
How can I give RollBack() in a transaction initiated in the declaration using? I know I can keep the transaction variable out of the using of SqlConnection, but it is possible RollBack() using the…
-
4
votes1
answer84
viewsCreate customizable parameter for Application Insights
In a Webforms project (C# - .NET 4.6.2) I am using telemetry Application Insights from Azure, I would like to send a custom parameter for statistics. Basically, I want to send Clientid to telemetry,…
-
4
votes1
answer1071
viewsCommunication failure with PHP webservice
I am trying to access a PHP webservice through an ASP.NET application ccbusca.pesqwebservice client = new ccbusca.pesqwebservice(); client.Url = "http://www.ccbusca.com.br/webservice.php"; ret =…
-
4
votes1
answer471
viewsC# - How to clear the "cache" of Visual Studio 2017 without having to close and reopen the program?
When I make a change to a library in Visual Studio Community 2017 I need to close the program and open again for the changes to take effect. The change I’m making is the documentation of a library…
-
4
votes2
answers223
viewsHow to get all constants of a class?
My project has a class helper with several constants representing roles predefined. public static class RolesHelper { public const string ModuloUsuarios = "Usuarios"; public const string ModuloMenus…
-
4
votes1
answer316
viewsIs there any difference in using the Read() method of the Sqldatareader object?
I am running the code snippet below, however, I was left with doubt related to the method Read() of the object Sqldatareader. using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows)…
c#asked 7 years, 8 months ago Diego Farias 909 -
4
votes1
answer220
viewsDevelop Windows 10 and Windows 8 compatible application
I am working on an application that we use Windows Forms to develop its alpha version. Soon, we will start developing a more stable version of this system, and, it was then that the support…
-
4
votes2
answers186
viewsHow to convert Two-dimensional array to a Single array?
I have the following definition of Two-dimensional Array: int[,] arrayBidimensional = new int[3, 3] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; The above variable does not have a method .ToArray()…
-
4
votes2
answers1511
viewsCipher de Vigenere
private static void algoritmo(String input, String chave, Boolean b) { Console.WriteLine("Digite a mensagem: "); input = Console.ReadLine(); Console.WriteLine("Digite a chave: "); chave =…
-
4
votes2
answers701
viewsCombobox read only
I’m trying to get a combobox read only (as the option ReadOnly of textbox), tampering with the properties of the object, but I’m not succeeding. The combobox is in a common windows form. It will be…
-
4
votes1
answer1109
viewsHow to change the color of the progress bar?
I’d like to do two things on my progress bar. Change color from green to red. Remove the blocks and create a color. I’m using Visual Studio Community 2019 on Windows 10.…
-
4
votes2
answers145
viewsHow to leave the background of Visual Studio 2008 in dark theme?
I use Visual Studio 2019 and love the dark theme, but lately I’m using 2008 for work demands and it has the white theme. It is possible to put it in the dark theme ?
-
4
votes1
answer1123
viewsWhat is the function called to drag the window to the corners of the screen?
How is called the function of clicking and dragging the title bar of the window to the corners of the screen, and they auto adjust? Example: when you drag the window in the right corner of the…
-
4
votes0
answers197
viewsc# outlook Sendeventhandler opening object only once
In my application I use Outlook Sendeventhandler to capture the click on the "Send" button of the email in outlook and open a screen to register observation regarding the email that was sent. I have…
-
4
votes2
answers2190
viewsConvert string to float on C#
What I’ve learned so far when we want to use the command Console.Readline() to read data that the user type we have to perform a conversion when this data is not of the type string, I know the…
-
4
votes2
answers278
viewsMatrix or Vector, huh?
What are the advantages of using a matrix, since the vector is easier to use and does the same things?
-
4
votes1
answer122
viewsComparison of Session and Viewstate with String
Recently, I received the following notice from Visual Studio in a code similar to the image: I understand what he wanted to say: there is a reference comparison of the two values (the session and…
-
4
votes3
answers609
viewsHow to compare 2 Arrays to Assert.Equals?
I need to compare two arrays on Assert.Equals. When I test the method in race it is right but the test does not pass. Code: public void SeparaStringTest() { RecebeComando recebecomando = new…
-
4
votes1
answer117
viewsIs it bad practice to use "Guid" and "int" for the same bank?
In a project I’m developing I prioritize the use of Guid for PK because of the ease for me, but it has a table that would be more advantageous to use int. This is wrong?…
-
4
votes1
answer777
viewsHow to transform a string into HTML C#
I am using a component and need to load it with HTML snippet that comes in a variable. For this I created this Jquery: $(document).ready(function(){…
-
4
votes2
answers820
viewsAccept only numbers in the C#console app
Good evening, I’m trying to get the Console.Readline() command to read only numbers, ignoring characters, there’s a way ? example: static void main() { int x; Console.WriteLine("INSERINDO VALOR PARA…
-
4
votes4
answers1049
viewsChanging HTML does not reflect on page - Asp . NET Core 3.0
I recently decided to test the ASP .Net core 3.0, I always changed HTML without the need to recompile the project, but in this version, I can’t change anything in HTML without the need to recompile…
-
4
votes1
answer289
viewsChr$ equivalent function in C#
I’m migrating a chunk of code in Visual Basic 6 and came across the following call: variavel = Chr$(27) & Chr(15) 1 - What would be the equivalent functions in C#? 2 - What is the difference…
-
4
votes1
answer65
viewsEntity Framework - Object exclusion with relationship
I have a question to understand the behavior of Entity. Because when I pass null Entity should not "clean up" the relationship in the bank? My Model: public partial class Ocorrencia { [Key] public…
-
4
votes0
answers83
viewsHow to insert references to use the Scriptengine class?
On the basis of the question Compile string as code includes in my project the class ScriptEngine, however, it is not being found in the references: using Microsoft.CodeAnalysis.Scripting; using…
-
4
votes0
answers90
viewsCreate an executable in c#
I am developing an application and I would like to know if it is possible to create an "executable" as an external program, for example: when clicking a button, it uses Savefiledialog to save the…
c#asked 4 years, 11 months ago João silva 79 -
4
votes1
answer113
viewsIs it possible to add icone to a program by creating in NET.core (Windows)?
I’ve only used the line commands dotnet, both to generate projects and to generate solutions (.sln), however I do not know if it is possible to use resource.rc directly with dotnet with something…
-
4
votes2
answers318
views"-" operator cannot be applied to a string
I’m trying to make some changes to a ready code, but I came across a problem with a line of code written in C#: string[] textArray1 = new string[] { -899253461.ToString() }; In this case, Visual…
-
4
votes2
answers129
viewsWhat is the difference between LINQ research forms with Datetime.Now?
I am running two code snippets and they are giving different results. Does anyone know why? This code shows coupons only that have the validity of the current date and time + 3h (I don’t know why):…
-
4
votes2
answers690
viewsReturn xml to preview browser Asp.net mvc
I have the following situation, I need to provide an XML file to be viewable in the browser, without the user needing to download the file, I do this by saving the file in a directory and then I…
-
4
votes1
answer1116
viewsWhat is a "Postback"?
It may seem like a silly question, but I can’t understand how a postback works, if anyone can explain to me thank you!
-
4
votes2
answers544
viewsMap Enum with search conditions
I have a class that makes the search conditions as follows: public enum EnumCondicao { [Display(Name = "Igual")] Igual, [Display(Name = "Diferente")] Diferente, [Display(Name = "Maior")] Maior,…
-
4
votes1
answer359
viewsUsing EF and Dapper in the same project
I’m making a simple insert of a user class, it is taking almost 10 seconds to record the information. So I tried to find other solutions to solve my performance problem and found the Dapper. My…
-
4
votes1
answer72
viewsHow to capture Stackoverflowexception
Hello, I am going through some problems on the server and with the application developed in MVC... I checked that the site was restarting the application pool alone, so I went to Event Viweer and…
-
4
votes2
answers159
viewsWhat’s the point of continuing flow control?
I found this code explaining the flow control continue. string [] nomes = new string[] { "Macoratti", "Miriam", "Pedro"}; foreach (string nome in nomes) { if (nome == "Miriam") continue;…
-
4
votes1
answer1394
viewsMany-To-Many Relationship Mapping - EF Core - C#
I’ve tried mapping a three-class relationship, but I’m getting it. I have a class Person who represents any Person, an Employee, a Customer, a Supplier, in short, any type of Person, be it physical…