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
answer2698
viewsC# - Import configuration file (.ini)
How I import an ini configuration file so that it is loaded and returns with a key value: Example: [version] code=0.3 the program will load the ini file and I select the section (in case it is…
-
4
votes2
answers731
viewsChange Context according to application
I need to point out in the web part what context the system will use. My project is divided as follows: After its completion I had to "replicate" it, but using another bank. The tables are equal…
-
4
votes1
answer284
viewsKnowing if a file is locked or not
How do I know if a file is blocked or not? I have perfected this code and I would like to know from you whether it is correct or for the better. Another question is if it is corrupted, the check…
-
4
votes1
answer241
viewsHelper for writing Htmlhelpers
I’m trying to write a Htmlhelper and seeing some basic examples I found one with the class TagBuilder that already helping: namespace MyNamespace { public static class MyHeleprs { public static…
-
4
votes2
answers92
viewsSetar schema in query with Repository
I have my Repository: public class RepositoryBase<T> where T : class { protected AppDbContext _context; protected IDbSet<T> _dbSet; public RepositoryBase() { _context = _context ?? new…
-
4
votes1
answer611
viewsDataannotation validating property with Javascript plugin. ASP.NET MVC
I need to validate a field of my model that has a text editor in Javascript. So far so good, because the problem only occurs in the registration that I do not receive in the parameter of the Action…
-
4
votes1
answer1682
viewsHow to obtain PDF content generated by Rotary?
I am using Rotary for PDF generation from a . cshtml I can download the file through the application correctly using the command below: DadosConvite convidado = new DadosConvite(); convidado.nome =…
-
4
votes1
answer405
viewsCompare two date attributes in the database with two Textbox
How can I compare a range of two dates? data_Inicio date data_Fim date textbox_inicio textbox_fim I can do this on the ASP.NET side and the goal is that my start date will never be less than my end…
-
4
votes1
answer5050
viewsHow to Read MFD Files Tax Hard Disk Printer
Is there any way to read MFD file tax printer that is on hard drive? These files are binary there is some way to read binary files and save with txt? Printer: BEMATECH MP-2100 FI…
-
4
votes1
answer1537
viewsDifficulties writing a user friendly (global) web config url
I asked that same question in the English version but I was unsuccessful! I have an application that will be translated into three languages en/en/es. Until then I’ll use Globalresources, I have no…
-
4
votes1
answer3207
viewsHow to check if an email has been sent successfully?
I am trying to verify if an email sent from my application is successfully sent, wanting to know if the recipient receives it or not (full mailbox, invalid email, around). From what I’ve researched…
-
4
votes1
answer1801
viewsPicking specific amount of characters from a textbox
I am trying to get a specific amount of typed characters in a texbox, the current code is as follows: novaconfiguracao.CupomEstabelecimento = tb_NomeFantasia.Text.Substring(0,48).ToString(); In the…
-
4
votes1
answer862
viewsProgress bar in windows c#Taskbar
I’m developing an app that will send email to multiple customers. I would like to display the progress of the shipment even with the form minimized. I would like to do the same way that Windows 7…
-
4
votes2
answers290
viewsHow to insert Entities, related to other existing ones, into the Entityframework?
In the case assuming an entity "Entidadea" that references an entity "Entidadeb", I want to save it, but referencing an entity B already existing ex: EntidadeA a = new EntidadeA(); EntidadeB b = new…
-
4
votes1
answer1165
viewsUsing Data Annotations to validate fields from an HTML page and Web API
Someone has an example of how to create a field validation in an HTML page using Data Annotation, Web API and C#. In MVC with you, this is easily achieved by using Wizard when creating a View.…
-
4
votes1
answer415
viewsDropdownlist with unique MVC values
My class Galeria possessed a foreign key with Album as there is a 1-n ratio and each photo in the item Galeria owned respectively a Album. Given this, in the CMS I created I give the possibility of…
-
4
votes1
answer938
viewsRDL Report of Report Builder 3.0 with MVC 4
I have a problem here, I made a system in C# using Razor MVC 4 with SQL Server 2014 database, so far so good... but now I need to generate reports, I made a report there in Report Builder and added…
c# mvc visual-studio-2013 asp.net-mvc-4 report-builderasked 10 years, 2 months ago Jeferson Santos 41 -
4
votes4
answers395
viewsHow to Debug only one project in Visual Studio?
I have six C# web projects inside a Solution in Visual Studio 2010, when running debug, Visual Studio launches the six projects at once, each of them in a different process. I wonder if there’s like…
-
4
votes2
answers801
viewsHow to change the value of a property given its name
In my program I have some classes where data is stored. For example Class1.alfa.dado = 66; Class1.beta.dado = 56; Class1.gama.dado = 37; The user will select in a Combobox one of the options you…
-
4
votes3
answers2598
viewsHow to know which component is in focus?
I am making a form (Windows Forms) in C# and I would like to know how to get the component that is focused. In my form there is a SplitterPanel and within it, in the Panel2, has a TabControl with…
-
4
votes2
answers576
viewsHow to create 1-N class relationships with more than one property and even subtype?
I have the following class structure, unconventional but it’s in the mold that I need to solve my problem: Tree: public class Arvore { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]…
-
4
votes1
answer147
viewsHow to show the build version?
I see in some pages and systems the compilation version. I’d like to show in a view the compilation version of my ASP.NET MVC project.
-
4
votes1
answer540
viewsHow to make Blur effect on button?
Is there any way to 'Blur' effect on an image button using C# (Windows Forms)? I know this is possible with WPF, but I have no way to change it now. If not possible, there is something that gives me…
-
4
votes1
answer2742
viewsDisable <Asp:Button after being clicked
Project in: Webform, C#, ASP.net I need to disable the button after being clicked. Today it is like this: <asp:Button ID="btn_Enviar" runat="server" CssClass="btn btn-primary" Text="Enviar"…
-
4
votes1
answer818
viewsWhat is the Dynamic Proxy generated by the Entity Framework?
What is the Dynamic Proxy generated by the Entity Framework? And a class? What is its function?
-
4
votes2
answers406
viewsError Mysql Connection Asp.net MVC
I am trying to work with a Mysql database in my application. However, I am getting the following error: Keyword not supported: 'data source'. I performed all the procedures related in this question…
-
4
votes3
answers1895
viewsDynamic Query in a List
How to apply a filter to an object List generic using Lambda? I know with Reflection i can get an array with the properties names of my object and through itself Reflection recover the property of…
-
4
votes2
answers646
viewsIs it possible to work directly with Entityframework fonts?
It is possible to work directly with the Entity Framework and power "thresh" within their classes and methods? I downloaded the zip from his code Codeplex. I unpacked in a folder and in my project I…
-
4
votes2
answers509
viewsHow to read the width and height of a physical image file?
How to get the width and height of a physical image file?
-
4
votes1
answer875
viewsEntity Framework auto relationship enable cascading delete
How to create a cascading deletion, in a self-relationship using the fluent api and enable this in entity framework? Code: Public class Usuario { public int UsuarioID { get; set; } public int?…
-
4
votes1
answer1395
viewsController message to view
I did that: [HttpPost] public void CadastraUsusario(string _nome, string _usuario, string _email, string _nivel_acesso, bool _ativo) { using (RupturaEntities db = new RupturaEntities()) { Usuario…
-
4
votes5
answers6761
viewsHow to create composite key with Entity Framework 6
I have my model base that all classes inherit from it: public class Base { public int Id {get;set;} public int ClienteId {get;set;} } And an example of model: public class Grupo: Base { public…
-
4
votes2
answers4228
viewsAuthentication in Restful Service
In the example below, I need to pass a login pair/password, because the REST service requires authentication (Basic Authentication). So how should I pass this information in the section below?…
-
4
votes1
answer66
viewsWhat are and how the following statements work in Web Forms pages: <% %>, <%# %> and <%: %>
I don’t know what they are or what to call them. Are they tags, statements? What are they? In practice, I noticed some characteristics. <% %> This statement accepts executable code, but…
-
4
votes1
answer208
viewsHow to send Email with HTML formatting to Windows Phone C#
Hello, Visual Studio 2012 has Emailcomposetask Object, but it does not have HTML formatting, I would like to know how to send emails via Windows Phone with HTML Formatting.
-
4
votes1
answer212
viewsHow to name the foreign key in the Entity framework
public class Lancamento { // Colunas e métodos omitidos [Column("IdContaBancaria")] public virtual ContaBancaria ContaBancaria { get; set; } } public class ContaBancaria { [Key] // PK…
c#asked 9 years, 7 months ago filipecampos 75 -
4
votes3
answers2878
viewsWhat is the best way to verify the existence of a record in the database via application?
Today I use a method that sends a COUNT with the record id as a parameter for the database. There is a better, perhaps more performative way to do this?
-
4
votes2
answers466
viewsMulti Banks / Cache / Client Layer
We are studying ways to develop some features for a system, which will be in C# . Net. I’d like to hear opinions on how we can do this, if we can use some frameworks or something else. Access to…
-
4
votes1
answer624
viewsFormat text in Crystal report
Well I’m needing to print a bankroll with following. Our number should look like this 15/200020-3. That same number is saved in the BD thus: 152000203. How do I put the bar in the 3rd house, and the…
-
4
votes1
answer162
viewsProblems with logic to bring data from a list or table
I did several posts here and solved almost all problems. However I understood that the problem was in the logic that I set up to bring the result. I know I’m asking a lot, but I’m trying and I…
-
4
votes0
answers120
viewsFailure in WPF stylization
I have a problem with references of a style within the code. I have a DLL of several stylized components inherited from the Telerik package with only a few changes like color, size, etc... Within…
-
4
votes1
answer495
viewsWhat are the positives of using Aspx View Engine instead of Razor?
When researching about ASP.Net MVC, I have always found all the examples of views with Razor (I don’t remember exactly if I saw any in aspx) and in the past I remember that it was possible to select…
-
4
votes1
answer153
viewsHttpmodule: How to handle Httpapplication errors without Httpcontext?
I have been finding a particularly interesting situation. I have a generic error handling routine implemented within a HttpModule, and recently I noticed a strange behavior: The event…
-
4
votes3
answers1368
viewsWhat better way to save a Group object that has Items lists?
I have a record and in it there are several links, for example: public class Grupo { public string Nome {get;set;} public List<GrupoItemA> ItensA {get;set;} public List<GrupoItemB>…
-
4
votes2
answers105
viewsWrong date calculation
I have the following method: TimeSpan dt = dataFinal.Subtract(dataInicial); double anos = Math.Floor(dt.Days / 365.25); double meses = Math.Floor(((dt.Days - anos * 365.25) / 30)); return…
-
4
votes1
answer394
viewsCode First Table Migration - N to N using Fluent API
I have the following classes: [Table("Area_Cursos_Turma")] public class Turma { public int TurmaID { get; set; } public virtual ICollection<Aluno> Alunos { get; set; } }…
-
4
votes1
answer734
viewsRegex take more than one occurrence in a string
I have my regex (\d{2}). And I got my string 12 hoje vai 45 na serra pelada 55 ou 75. How do I get my regex to pick up all occurrences of the string? It’s only picking up the last one.…
-
4
votes2
answers1303
viewsPicking up content within a string
I’ll have a list of string in the following format: PERSON’S NAME( (LOGIN), an example would be this: ZACKSON MOREIRA MORGAN (zackson.morgan) Soon, I would need to get just what would be inside the…
-
4
votes1
answer430
viewsHow do you find the term X in the Fibonacci sequence?
I have to do a C# program that gets a number X which will be the term of the sequence and print it on the screen.
-
4
votes3
answers152
viewsViewdata error in controller
What could be wrong in this example? I can’t do it: var pessoa = new Pessoa ( PessoaId = 1, Nome = "teste teste", twitter = "@teste" ); Error message: 'Name' does not exist in the Current context…