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
answers1558
viewsGlobal variable query in a controller
I have a method in my controller that is called through ajax. It populates a global variable within that controller. Is there any way I can access this global variable already populated by the first…
-
4
votes1
answer600
viewsHow do I know if a client is accessing the server over the local network or the internet?
How do I identify if the client who is accessing my application, whether it is within the company (local network) or outside (internet)?
-
4
votes4
answers2257
viewsCheck if user is logged in
I would like to know how to block access when the user is not logged in to the system, however, the only page that can be accessed is the Login and when he tries to access any other page redirect to…
-
4
votes1
answer310
viewsHow to go through all the controls of a WPF window?
Is there any way I can go through all the controls of a window and disable them? For example, do a foreach that disables one by one of the controls. Something like below, only for WPF, and not…
-
4
votes2
answers304
viewsHow to store the Selecteditem value from Dropdownlist in the database?
I want to register a client and one of his attributes is sex Database: the sex attribute is a nvarchar ASP.NET: I am working with a listview to enter client data <asp:SqlDataSource ID="clientes"…
-
4
votes2
answers3760
viewsCalculation of the multiple of 10 greater than or equal to a value
use module 10; Example: 7 4 8 9 3 1 0 7 2 <== Dados x x x x x x x x x 2 1 2 1 2 1 2 1 2 <== Peso = = = = = = = = = 14 4 16 9 6 1 0 7 4 <= Resultado 1+4=5 1+6=7 //resultado da multiplicação,…
c#asked 9 years, 7 months ago Fabrício Mendes 843 -
4
votes1
answer2873
viewsHow to set today’s date as default value in a texbox as date input type?
I have a research page for a sales report and I use a textbox that generates a input type "date", and whenever the page loads the value of the field is "dd/mm/yyyy". I would like that whenever the…
-
4
votes1
answer156
viewsRegular Expression, picking numbers between two predefined texts
I need to withdraw números of a string. To string follows a pattern: http://www.meudominio.com/1789519-texto The number will always be between / and - I’ve already reached the following formula:…
-
4
votes1
answer1107
viewsUnit test of implementations of a Generic class
Suppose we have the following interface: public interface ICRUDService<T> { T Create(T entity); } Abstract implementation: public abstract class CrudService<T> : ICRUDService<T> {…
-
4
votes1
answer369
viewsCharacter Camera does not move!
I’m doing a tutorial on Unity that I downloaded in the Asset Store on the following link https://www.assetstore.unity3d.com/en/#! /content/21028 I tried to make my character rotate to look towards…
-
4
votes1
answer495
viewsWebbrowser with input type file
Friends, I am building a virtual robot to act on a particular site. In a given action I need to upload a file to the site, but when the robot clicks on the button <input type="file"> logically…
-
4
votes1
answer4227
viewsRemoving part of a string - C#
How can I remove my last characters from a string before reaching a certain character? For example: string url = "www.google.com/test"; I needed to remove the test word until I reached the "/"…
-
4
votes1
answer156
viewsHow to get Timezone?
I have the following code: var minhaData = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, meuTimeZone); Case meuTimeZone = "E. South America Standard Time"; then the value returned to…
-
4
votes1
answer61
viewsWhy can’t I access a field but the method can?
I have the following code in C#: namespace ConsoleApplication4 { public class BaseClass { public BaseClass() { System.Console.WriteLine("BaseClass::BaseClass();"); } } public class DerivedClass :…
-
4
votes3
answers3047
viewsUnfulfilled Nfe XML
Well, I’m trying to do the reading for import of XMLs of the Electronic Tax Notes and I’m having a lot of difficulty in disemboweling the ICMS of the blessed. No problems to reach the object ICMS:…
-
4
votes2
answers83
viewsPersistence using Fluent API
How do I persist an address without having to pass on all customer information? Below is my address client mapping: HasMany(f => f.EnderecoList) .WithMany(e => e.ClienteList) .Map(me => {…
-
4
votes2
answers1380
viewsCapture Machine Identification with C#
Good morning, I have several computers with the same output IP, how can I get any information that leads me to know which computer a request came from? I use C# Asp . Net MVC
-
4
votes1
answer180
viewsUpdate Controls in Custom Toolbox Control
I created a project "Windows Forms Toolbox Control" and customized some controls: I created a custom gallery so that all programmers in the company can install Toolbox and make use of the controls:…
-
4
votes1
answer954
viewsHow to create a foreign key in a table where data already exists, in Entityframework with Code-First?
I have a system already in production of which the client requested a modification. The modification is the creation of an EMPLOYEES table that will relate to the MOVEMENT table, creating a 1:N…
-
4
votes3
answers3309
viewsGenerate PDF with Asp.Net MVC
Hello, in my application the reports are generated in Html, I would like to know a way to generate these Html reports in PDF.
-
4
votes3
answers9903
viewsGet the last N characters from a string
I have a string which in reality is a phone number. But a phone number can have some formats like: +55 34 98989898 34 989898 989898 The constant is that always the last 8 numbers are the phone…
-
4
votes1
answer1780
views'Copy text' button in C#
I’m new to C#, and wanted to create a button that when clicked, it will copy the text described in that same button. If I didn’t make myself clear, imagine button has a text inserted in it (eg:…
-
4
votes3
answers1608
viewsIs it possible to backup a remote bd sql server via c#?
I am using Assembly Microsoft.SqlServer.Management.Smo to back up an Sql Server database to c#. The problem is that the way it is implemented I can only perform the action if I am running the…
-
4
votes1
answer122
viewsWhy does Arrays implement Ienumerable but not Ienumerable<T>?
I was making a class that contains an Array of the class Episode: public Episode[] EpisodesList; Then I implemented the IEnumerable<T> in my class. And as expected, I implemented the method…
-
4
votes2
answers322
viewsRead document array of word bytes in browser
I have a routine of upload and download on a website that is working. However, I cannot do view word type files, directly in the browser, I wish to view as pdf. What I’m doing is saving the document…
-
4
votes1
answer269
viewsHow to calculate with 3 variables of type Datetime?
I have these 4 variables: public System.DateTime TempoOtimista { get; set; } public System.DateTime TempoProvavel { get; set; } public System.DateTime TempoPessimista { get; set; } public…
-
4
votes2
answers590
viewsOpen subdirectories with explorer in C#
I am making an application whose purpose is to search and open a subdirectory inside a folder that is on a server. But what I can do so far is just search and open the folders that are at the…
-
4
votes1
answer937
viewsEntity Framework attribute list for entity mapping
For my sake Database be outside the EF convention, and as another system already developed uses it, it is out of the question to change table/column names. I would like to know the available…
-
4
votes1
answer851
viewsHow to get the path of a file (Httppostedfilebase)?
I would like to get the path(path) from where my file is coming from. Model: [Required(ErrorMessage = "Selecione o arquivo a ser importado.")] [Display(Name = "Arquivo ")] public HttpPostedFileBase…
-
4
votes1
answer294
viewsIs it possible to make a condition within a Select?
I’m performing a consultation using Select, to select only the required fields and consequently have higher performance. In my View user can choose certain fields to be loaded Man ViewModel public…
-
4
votes2
answers1182
viewsHow to remove mask from the field before calling the controller with Asp net MVC
In my registration form I have a CNPJ field with the mask set via jquery $("#cnpj").mask("99.999.999/9999-99"); however the value is coming in my formatted controller, in my database this field is…
-
4
votes1
answer199
viewsConvert string to specific format in date
I have a string "sex, nov 6" and need to convert to DateTime. I’m doing it this way: DateTime datetime = DateTime.Parse(gridT.Columns[e.ColumnIndex].HeaderText.ToString()); But it’s not working. How…
-
4
votes1
answer647
viewsProblems authenticating to Report Service 2014 server via C# MVC5 application
I’m having a problem connecting to the Report Service 2014 server via C# of an MVC4 project: Setting: A Server Report Service 2014 has been installed that will have numerous reports, due to the…
-
4
votes1
answer61
viewsRun a method when Webservice is Started
I have a Webservice that’s working normally. At this point arose the need to execute a method called "Recuperaraposfalha" that needs to be executed as soon as the Webservice is started. This is a…
-
4
votes1
answer1630
viewsMonetary values with Asp.net MVC
I am facing difficulty in working with monetary values (decimals) using web application, asp.net MVC, with database Mysql. The problem is I can’t edit decimal values, like: 53.50, or 53.50. I can’t…
-
4
votes1
answer1174
viewsRazor C# list and sublist with List<String> (originally "how to check if an HTML element already exists")
I need to know if an HTML element already exists, in my loop, if it exists I use it, if it doesn’t exist I create a. How would you do it inside a @foreach (var item in Model){ ... } Following the…
-
4
votes4
answers4483
viewsExtract decimal part of a decimal
I’m having trouble formulating a good means of extracting the decimal part of a variable decimal, so far the existing implementation in the system is that: public static bool…
c#asked 9 years, 4 months ago Marciano.Andrade 1,205 -
4
votes2
answers2019
viewsError while running project in Visual Studio 2015
When compiling gives sucessfull, but when I try to run my project I get this error below. Can someone help me or give me a hint? Use the visual studio 2015. Severity Code Description Project File…
-
4
votes1
answer8783
viewsHow to set Grid View column width?
I would like to know how to define the width of the DataGridView manually. My first column has to have a fixed value and the other columns must "fill" the grid so that they are the same size.…
-
4
votes2
answers514
viewsC# how to do database search using parameters
I have the following code public DataTable PesquisarPorNome(string NomePesquisado) { try { DataTable tabela = new DataTable(); SqlDataAdapter adaptador = new SqlDataAdapter("SELECT * FROM…
-
4
votes1
answer1358
viewsCatch Penultimate record of a table with Entity Framework
How do I get the penultimate record from an Entity Framework table
-
4
votes1
answer643
viewsProblem with Decimal (4,2)
I have an MVC project, I am using Entity Framkework and in my database there is a table with a column of type decimal (4,2). The problem is: I try to insert any value, for example: 5.00 // 5,00 //…
-
4
votes1
answer201
viewsI cannot remove a reference installed by Nuget
I installed the DLL Log4net for nuget. Since it’s in a different version of ours and a colleague gave it to me as usual, I deleted it from the folder and put the current one. When I build the…
-
4
votes2
answers93
viewsCheck two null fields with Data Annotation
I own two properties: public int? Inicio {get; set;} public int? Final {get; set;} Both accept null and are not required. I wanted to check if both are null using Data Annotation. The operation…
-
4
votes1
answer108
viewsError in . First(), as there is no selected result
In my controller of Login I use the following code to select the user if it exists, but whenever the user type the incorrect name or password, it gives an error, because it does not find the result…
-
4
votes1
answer93
viewsOnselectionchanged MVC
Late, How can I call the Onselecionchanged event from a DDL using MVC? I have the following DDL: @Html.DropDownListFor(model => model.Type, ViewBag.Type as SelectList, "-- Select --", new { id =…
-
4
votes2
answers4976
viewsRemove the time part of a date in c#
This is not working: DateTime? _data = calDataExclusao.Date; string nova_data = _data.ToString("dd/mm/yyyy"); The mistake is: No Overload for method 'Tostring' takes 1 Arguments How I remove the…
-
4
votes2
answers1678
viewsInsert image into email body
How do I insert an image into the body of the email using C# ? I have already been able to send as an attachment but I would like to know how to proceed to send it in the body of the email , has…
-
4
votes2
answers10482
viewsDoubt about "Error Converting data type varchar to float"
Error Converting data type varchar to float This error is occurring when performing a Update in a table, follows below the code: SqlCommand cmd = new SqlCommand("UPDATE Notas SET nota = '" +…
-
4
votes1
answer454
viewsReturn Partialview with validations for a Modal ASP MVC 4
I have an Index screen, where is the table of registered people, on the same screen I have a new button that calls a Modal(boostrap) this way: <a href="@Url.Action("Add", "Pessoa", new { area =…