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
votes2
answers1662
viewsHow to convert to Base64 in C#?
I am using Webforms. There is a certain part of this application where I send, through Ajax, a string Base64, which is the code of an image. I’m used to using PHP and use the functions base64_encode…
-
4
votes1
answer196
viewsVB6 always executes the 2nd function even though the 1st is False
The if in VB6 always executes the 2nd function even validating that the 1st is False, C# does not execute the second function in case the first one is already false. How can I get the vb6 to perform…
-
4
votes3
answers2308
viewsFormat double output with dot instead of comma
I have a collection of coordinates to popular the Peater, with city name, latitude and longitude. .aspx <form id="form1" runat="server"> <div id="repetidor"> var markers = […
-
4
votes3
answers328
viewsFormat integer value in "000" format
In vb6 used the following line of code that allowed formatting the value "1" to "001" Format$(Nivel, "000") In C# I am using the following with similar nomenclature. string.Format("000", 1); However…
c#asked 6 years, 6 months ago Daniel Fernandes 235 -
4
votes3
answers221
viewsList<> Best practice, start with fixed capacity or start without limit?
I have a scenario where I will receive a list, or an array, or any other type of data from the database where I can know the size of my list before creating it, what is the advantage between the…
-
4
votes2
answers84
viewsHow to list bookings registered by a single administrator? (1:N)
I register my attributes from the Reserve class, logged in as an Administrator. I would like to know how to list these registered reservations, by a specific administrator? Example: Administrator 1,…
c#asked 8 years ago Allan Fernandes 129 -
4
votes3
answers87
viewsPut date in American format with substring
How to put the string 22012018 What is a date in American format to save in the database? The code below returns me the value: 2018-22-01 I mean, YEAR-DAY-MONTH The right one would be YEAR-MONTH-DAY…
c#asked 6 years, 6 months ago Igor Carreiro 1,917 -
4
votes3
answers3627
viewsFormat a string for phone format
I have the following string "49988070405" and I want to format it for "(49) 98807-0405". I tried the code: Convert.ToUInt64("49988070405").ToString(@"\(00\)\ 00000\-0000"); But to no avail…
c#asked 6 years, 6 months ago Matheus Saraiva 2,157 -
4
votes2
answers192
viewsWhy is there no String.Toint() method?
String in C# is an object, right? From what I saw to string is a class, different from int and other primitive types that are simple types, (I’ve seen on another site too, that they are all objects…
-
4
votes3
answers11041
viewsPrinting text file on thermal printer with Printdocument?
I am developing a system in Winforms with C# and now I need to generate a sales receipt coupon and print on a thermal printer. I’ve been reading about Printdocument but can’t find examples of how to…
-
4
votes5
answers1602
viewsChange return /Date(1386295200000)/ to date format
I have a return from json that comes so from SqlServer: /Date(1386295200000)/ How to convert to date format dd/mm/yyyy?
-
4
votes1
answer469
viewsHow to save in 2 tables at the same time
Hello, I would like a help. I have this method to save the data in two tables. public void SalvarLocacao(Carrinho carrinho, Locacao locacao) { Item items = new Item(); foreach (var item in…
-
4
votes4
answers2605
viewsBreakpoint in visual studio does not load at debug
I have a solution with 3 projects, one of them being Ex.utils and Ex.Api. Where the . dll of the utils project is referenced in Ex.Api in 'References'. Both compiled in the same version of . NET.…
-
4
votes1
answer2113
viewsHow do I exchange text in unity3d with a script I can’t remove?
I have a problem in unity3d and I don’t know how to solve. I have a certain script using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; using UnityEngine.UI; public class…
-
4
votes1
answer1658
viewsIssues with accentuation when reading data from JSON file
The method below is extracting data from a JSON file, to fill a Dropdownlist. public static List<Uf> GetAll() { var client = new WebClient(); JsonSerializerSettings settings = new…
-
4
votes1
answer242
viewsWhat is the difference between Xmldocument and Xelement?
I’d like to know the difference between Xmldocument and Xelement.
-
4
votes4
answers174
viewsComments weigh the code in C#?
I use the C# language with Unity Engine and, as several programmers have access to the code, we usually comment a lot so that everyone can understand what is there. I saw in other responses…
-
4
votes2
answers177
viewsC# - Problems reading data from an XML returned from a site
I want to take the Location of an external IP and for that I used a site where I simply put the IP I want and it returns the XML with the information. Example: freegeoip.net/xml/4.2.2.2 that is to…
-
4
votes0
answers4243
views'The underlying Provider failed on Open' C# ASP.net
I have an application that has 4 layers, which are the following : Dominio, Infra, Servico, Web in the domain I have a folder called Poco with all my Classes/Tabelas , in the Layer Infra, to test…
-
4
votes1
answer402
viewsUpdating a collection object’s values via Binding WPF, MVVM
Following MVVM model, I am not able to update the values of a variable of an object in a collection, show them on the screen or the user type and this value be passed to the variable. In my case, I…
-
4
votes3
answers546
viewsConvert char to integer in C#
Reading a blog article, I came across the following syntax for converting char to integer: string value = "123"; foreach (var c in value) { if (char.IsDigit(c)) { int digito = c - '0'; } } I wonder…
-
4
votes1
answer499
viewsDelete user session in ASP.NET MVC with [Authorize]
I have a web system developed in ASP.NET MVC 4. One of the features is user management. A CRUD of users. My method of login is as follows: [HttpPost] public ActionResult Login(LoginViewModel…
-
4
votes2
answers1274
viewsHow to redirect user to page after login?
I am developing a web application, using Asp.Net MVC 5 com Identity and I’m using Roles to carry out the authorisation. I’m trying to do that depending on the Role that the user has, it is directed…
-
4
votes1
answer151
viewsUnique contexts of authenticated users
Using the @Gypsy recommended method in this answer (It is possible to leave connectionString dynamically?), I was able to get a dynamic connection, and using the idea of mapping a context with the…
-
4
votes1
answer991
viewsHow to use login in different areas on Asp.net mvc
I’m creating an app, where it has more than one Area, which is restricted. (as shown in the image below). My question is how to login in different areas? Details: As users of the Admin area and the…
-
4
votes2
answers175
viewsShould I make sure the threads end at Dispose?
There are already some questions about the interface IDisposable and the using, for example: What types of resources are released in a statement using I should always use Disposis Still I’m not sure…
-
4
votes1
answer110
viewsHow to change chart when changing date
First I apologize for my lack of knowledge of some concepts, I am new in the area. I recently started in a company where I have the following problem: I have a Datepicker and when selecting a date,…
-
4
votes2
answers72
viewsVisual Studio 2015 says "this" is redundant
In the early days of my first object orientation classes I was taught to use the thiswhere it is a variable or class property. Today I understand when there is a real need to use, for example when a…
-
4
votes1
answer151
viewsProblem with null variable
I’m developing software in C# with MVVM model, and with Visual Studio. It is a software to manage the members of a university. We must also use a database, with Code First. My problem is it gives me…
-
4
votes1
answer101
views -
4
votes1
answer256
viewsWhat is the purpose of a TT extension file?
Well, I was searching around the Internet for a way to create a string as template, based on an archive of template. I came across an answer from SOEN that talks about files .tt, to use a template…
-
4
votes1
answer1201
viewsHow to update a Dropdownlist without refreshing the page
I have a State Dropdown, and a City Dropdown, and a zip code field, which is making use of the mail online API, when I put a zip code, my system checks whether the city already exists in the…
-
4
votes1
answer75
viewsC# float++ and float-
I used the following code snippet: bool plus = false; int index = 0; index = plus ? index++ : index--; the index result is 0 and do not know why, when I do the way below it works: index += plus ? 1…
c#asked 6 years, 2 months ago Roberto Gomes 455 -
4
votes3
answers702
viewsFunction that takes another function as a parameter in C#
In the language Lua has how to create a function that takes as argument another function, for example : exemplo = function(outrafunction) outrafunction() end exemplo(function print("alguma coisa")…
-
4
votes1
answer266
viewsSave dataset C#
I’m searching several tables from the database for a Dataset through a Stored Procedure in the MySQL using the Mysql Workbrenck, but when saving only the first table is saved, my code: Stored…
-
4
votes2
answers3123
viewsError saving Datetime type field
I am mounting an example of Code First, but when saving a field of type Datetime in the database returns me the following error Conversion of a datetime2 data type into a datetime data type resulted…
c# entity-framework-6 crud sql-server-2012 migrationsasked 7 years, 10 months ago Marco Souza 12,304 -
4
votes1
answer799
viewsConsole in windows Forms application
I have a class where opens the console, shows some data and then closes, when running a second time (without closing the program), an exception occurs in Console.WriteLine("") If executed once,…
-
4
votes2
answers392
viewsOpen View with Parameters
I have this Script: $('#Musico').change(function () { var id = $(Musico).val(); var url = '@Url.Action("Votar","Chamada")'; var tipo = 1; $(function ChamaVotar() { $.post(url, { id: id, tipo: tipo…
-
4
votes1
answer205
viewsWCF Receive Reply in UTF-8
I’m consuming a Webservice by means of a Console application. I receive an object as a return and in this object I need to read an attribute called ReturnMessage. But the text is disfigured, the…
-
4
votes3
answers218
viewsPublic field X property
I have a string defined as "name" initially it is as private. string nome; In case I assign the methods get/set, and to stay in the pattern I change the initial letter to uppercase, getting: string…
-
4
votes2
answers132
viewsSHA512 hexadecimal return
I found an example of encrypting a string with SHA512. public static string HashedString(string text) { SHA512Managed sha512 = new SHA512Managed(); byte[] hash =…
-
4
votes2
answers353
viewsWhat is the difference between @Url.Content("~/css/bootstrap.css") and only "/css/bootstrap.css"
I am learning to program an application based on MVC4 and Bootstrap. At the beginning of the project I came across a puzzle: In the _Layout.cshtml I had <link href="css/bootstrap.css"…
-
4
votes1
answer2349
viewsWhat is the reference to Httpcontext.Getowincontext() ?
I had to abstract the Controllers of an application ASP.NET MVC for a Class Library because I’m using different technologies in the same application. However, I have the error:…
-
4
votes1
answer1934
viewsClass Factory Recovery Failure - Console Application
I have a Console Application that performs connection with the SQL. On other machines the application is working normally, but has one that has the version Windows Server Enterprise SP2 who is…
-
4
votes1
answer1938
viewsc# Nhibernate a Different Object with the same Identifier value was already Associated with the Session
I’ve been with that mistake for a while and I can’t find a good solution. Saving objects works normally, but for changes it returns me this message: Additional information: a Different Object with…
-
4
votes1
answer618
viewsRegular expression does not validate password when I type only numbers
I am using this regular expression to validate my password, the password must have only letters and numbers, must have at least a letter and a number. (Minimum 8 characters). I’m using that…
-
4
votes1
answer1448
viewsHow to toggle lines of a report with custom colors Crystal Reports and C# winforms?
In the report I’m doing, I’ve managed to alternate colors by doing the following: Access to the Menu: Crystal Reports - Report - Section Expert Select the section Details and click on the tab Color…
-
4
votes1
answer48
viewsError There are no comments for in the schema
I’m following a tutorial to access database via LINQ. In the video, I saw a function that returns me a list with the database data: public static List<LicitacaoOffline> Buscar() {…
-
4
votes1
answer3984
viewsTimezone do Brasil para Datetimeoffset C#
I’d like to know what’s possible Timezones available for all regions of Brazil. I saw we got the E. South America Standard Time for Brasília’s time, but for example, what would be the Timezone acre?…
-
4
votes1
answer4254
viewsC, C++, C#? Why should a beginner start learning?
I am 17 years old and I am learning Java, when I feel that I already master the language I plan to migrate to . NET! What is recommended to start C, C++ or C#? Thanks for the help ^^