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
-
2
votes1
answer1238
viewsDoes C# support GPS?
It is possible via a computer I find the location of a cell phone with altitude, longitude and latitude using C#? Is there a library for that? Do I need any specific hardware to be able to put into…
-
2
votes1
answer459
viewsConvert ASP.NET datatables to different Excel SHEETS
How can I create more than one sheets converting different datatable for excel? My code: DataTable dt = new DataTable(); dt = Tr.Get(); GridView x = new GridView(); x.DataSource = dt; x.DataBind();…
-
2
votes1
answer71
viewsHow to make a global event
I develop a system in which, a user can send a message to another, (which is saved in the database, to have a conversation history), but I would like that while the user is using other functions of…
-
2
votes2
answers1303
viewsHow to do a ZIP search in VB
How do I collect address data(Street, City, Neighborhood, Street) of a site, referring to the entry zip code using VB? I have a similar code on C# I see two alternatives: Translate the code to VB…
-
2
votes1
answer841
viewsConvert Enum variable to int in C#
I have the following code: enum type = { OPEN = 0, CLOSED, UNDEFINED}; list<int> frequencia = new list<int>(new int[] {0,0,0}); I would later like to carry out the following operation:…
-
2
votes1
answer537
viewsAjax request in C# update authentication
as I do for each Ajax request, update the Forms Authentication cookie. I want to update on Forms Authentication in my controller, because it is a calendar screen that uses Fullcalendar. I’m having…
-
2
votes1
answer460
viewsReceiving several Textbox values
Need to edit multiple records simultaneously, more specifically a list of students and load/edit from several textboxlinked to such. Basically I need to give/take their presence. How could you…
-
2
votes1
answer168
viewsSQL does not work on another device after publishing to the web
Because my page cannot run queries to the bank when it is published on the web and being used from other devices (computers and smartphone networked)? If I use it from the computer itself (server),…
-
2
votes1
answer295
viewsError while reading XML
When I try to read the xml, return it to me: {System.Linq.Enumerable.WhereSelectEnumerableIterator<System.Xml.Linq.XElement,SSP.Class.ListaConsulado>} XML: <?xml version="1.0"…
-
2
votes2
answers3231
viewsSome method to save data from an Arraylist
First of all, some information: = .NET Framework 4.0 = Visual C# I’m simulating a database using a class specifically for this, using a List<string[]>, however, I would like to be able to…
-
2
votes2
answers1179
viewsHow does MVC layer-to-layer communication work?
I started studying MVC, but I’m still in theory and I was wondering how the conversation between the layers works in practice. One could give an example of C# code without using the MVC framework?…
-
2
votes1
answer424
viewsRedeem a Datatable ID inside a Gridview
I’m trying to rescue the ID of my client who is in a GridView, but I’m using a DataTable to fill the GridView. Datatable public DataTable SelecionarDT() { objDAO = new ClienteDAO(); DataRow dr;…
-
2
votes1
answer593
viewsHow to use LEAD and LAG using a condition
My question is, if I can use LAG and LEAD, using a condition in the query, for example: I have the spine cep.. I want to take the value of the next row, and the value of the previous row of that…
-
2
votes1
answer214
viewsSave entities with one relationship to many using Webapi
I am starting a project in Webapi and came across a situation that did not know how to define my class of Controller. I have the following structure public class Artigo { public int ArtigoId { get;…
-
2
votes4
answers1315
viewsHow to group code and add existing amounts in text files with C#?
I have several text files inside a directory. I need to do in C# and join all the text files in a final text file, but treating their contents. Example: Arq1.txt 123456010 654321020 Arq2.txt…
-
2
votes2
answers174
viewsReceiving code 200 when it should be 404
I created an ASP.NET MVC 5 application by adding the following code snippets: Web.config <system.web> <customErrors mode="On"> <error statusCode="404" redirect="~/Erro/Erro404"/>…
-
2
votes4
answers2258
viewsConditional Data Annotation MVC4
I researched pacas here and did not find a solution for what I wanted. I wonder if anyone has done something similar in MVC4. Model: public class Trabalhador { [Required(ErrorMessage = "*")] public…
-
2
votes1
answer66
viewsExpression inside a lambda gives error
I created a lambda and tried to create an expression or other. With or(||) it didn’t work. Then, instead of || I added Where. Is that right? This way now: var resultado = db.T_CRM_StatusPDV .Where(a…
-
2
votes1
answer434
viewsMvccheckboxlist, Radiobuttons and Text Inputs
I have a project where I’m using Mvccheckboxlist. My question is this:: Could I put a mvccheckboxlist together with radio Buttons and inputs ? Because I am in a project at a school that I have to…
-
2
votes1
answer1300
viewsCalculate date difference and compare with integer field in lambda expression
I have a data field (Datetime) and also an integer field. I need to make the difference between this date field and today’s date (Datetime.Now) and compare whether it is larger or smaller than my…
-
2
votes2
answers495
viewsLambda Expression X
Speaking in terms of overall performance (speed, integrity and etc...), using English expressions to query database, is better in the above terms or depends on?
-
2
votes1
answer338
viewsCreate Web Service by repurposing code from an already published site. Good practices in Asp.NET MVC
I need to create a web service in JSON reusing as much code as my site has, but I don’t know how to do it, if I should add a Solution to my site project etc. I can’t abstract the idea, I need to…
-
2
votes1
answer325
viewsMSBUILD - How to Publish Multiple Single Solution Projects (OSGI)
I’m in need of some help publishing my projects. I am using OSGI to modulate my application, with consequence in my Solution there are several WEB applications. Ex: Solution A 1. Aplicação 1 2.…
-
2
votes1
answer1367
viewsGet list of checkboxes in the controller in Asp.Net
How do I get a checkbox list like this: <div class="editor-field" style="overflow-y: auto; height: 150px;"> <label>Especializações:</label> @{ if…
-
2
votes2
answers1437
viewsHow do I catch Id on the return of a Web Api Post?
I have this code on Web Api: [ResponseType(typeof(Menu))] public async Task<IHttpActionResult> PostMenu(Menu menu) { if (!ModelState.IsValid) { return BadRequest(ModelState); }…
-
2
votes2
answers2389
viewsStored Procedure with output parameter being the Id of the last insertion. C#
Hello, I’m performing an insert in a table, but I need it to return the ID you just entered. I searched on the command OUTPUT but I couldn’t solve my problem. I need to do all this using procedures,…
-
2
votes1
answer46
viewsWhich reference to import into Tableattribute?
I’m not getting my application to find the table tag. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Dominio { [Table("Loja_Carrossel")] public class…
-
2
votes1
answer247
viewsHow to use Reflection
How and why to use Reflection? Is it very useful in everyday life? Its use offers some gain for the system itself?
-
2
votes1
answer376
views -
2
votes1
answer959
viewsThis Assembly does not allow partially reliable callers
I have my project, and in it I have a dll to access some methods, developing works normally, but in the approval environment this giving this msg: "This Assembly does not allow partially reliable…
-
2
votes2
answers1040
viewsNull check returns reference error
Model public class Transacao { [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int ID { get; set; } [Required] public DateTime Data { get; set; } [Required] public decimal…
-
2
votes2
answers513
viewsHow to put between within a code query?
I have the following consultation and I would like to put in the clause Where the condition of being within a certain period. public static DataTable stCloseCaseAll(int schoolId, string dataInicial,…
-
2
votes2
answers6591
viewsError trying to establish connection between SQL Server 2014 and Visual Studio
I’m having problems connecting Visual Studio 2010 [c#] with Sql server 2014. I followed some tutorials but did not succeed. Why is such a mistake happening?…
-
2
votes1
answer627
viewsImage upload using Webservice C#
I would like a help to know what is the best way to upload an image using webservice c#, I have tried several forms and several examples but could not. I tried to convert an image to string Base64,…
-
2
votes1
answer135
viewsDifficulty positioning controls with bootstrap
I have a cshtml, that needs to position some controls. I positioned a table on the left side of the document. Now I need to position several controls labels next to the table and these labels one…
-
2
votes1
answer1692
viewsHow do I read a Datagrid, line by line?
I have a DataGrid (WPF) filled by an external data source. I need to rotate the entire grid, checking the values of each row, column by column. How is it possible to do this? What is the "heart" of…
-
2
votes1
answer1306
viewsChange Webservice address at runtime - C#
I am developing an application that should connect to several Web services according to the user’s location. For example: If the user is in the city "To" it will connect to the web service:…
-
2
votes1
answer56
viewsrecover text from onmouseover statusbar
It is possible to recover text from status bar? on Windows.Form on VB6 could. I wonder if in C# it would be possible
-
2
votes1
answer310
viewsMake a query using Entity Framework and Stored Procedures
I have the procRetornaCliente process that receives the following parameters: Id, areaAtuacao, City. Mapping it on EDMX, I got a Complex Type (procRetornaClienteModel) with all fields mapped, but do…
-
2
votes3
answers3089
viewsPublication of MVC 4 site on IIS is giving error
I uploaded my published application to IIS and I can’t see in the browser. Before I was giving error of Forbidden(403) and now of Server Error(404). I’ve never uploaded an MVC site to the IIS. I…
-
2
votes1
answer601
viewsCan we create the business rule in our model?
What best practice? Create the rule in the model itself or create another class Ex: public class Item { public void Faturar() { //fatura item } } ou public class ItemBLL { public void Faturar(Item )…
-
2
votes2
answers173
viewsIs having two dbContext for the same Connection string considered bad practice?
I initially had a DbContext with all the DbSets of my entities. However, I needed to create a DbContext<T> who owns a DbSet generic for methods that are properly generic. It turns out that the…
-
2
votes1
answer599
viewsTaking an object from a list by reference and not by position
Hello, I would like to know how to create a list of objects in C#, but instead of picking them by posição ([0], [i]), I want to take by reference [LacoAzul] [CorVermelha]. You can create a list like…
c#asked 10 years, 2 months ago Junior Dias 741 -
2
votes2
answers917
viewsAmount of a given character contained in a Stringbuilder
I have a Stringbuilder with these values: 12********3*4*. There is a simple way to return the amount of asterisks without having to do a go over my Stringbuilder? I’m using C# with Net Framework 3.5…
-
2
votes2
answers942
viewsMulti Language ASP.NET MVC
I have an ASP.NET MVC application. And I need to make it multi-language, using a database. I thought of two approaches: Livro Titulo Subtitulo Idioma OR Livro Titulo TituloEN Subtitulo SubtituloEN…
-
2
votes3
answers42978
viewsHow to make a select with multiple `Where field like '%'` in C#
select below even works, but it searches all fields and would like the idaluno, nomealuno and cpf were searched and ordered by idaluno SELECT…
-
2
votes1
answer220
viewsHow to list related data
In my project I have two tables: Student and Occurrences. And they are related so that a student can have several occurrences. My need is: In the Student Details view (Details.cshtml), I need to…
-
2
votes1
answer2238
viewsError in the query
I’m trying to make a query in the table below, from my database. This query is performed through the method below: public void compraAcoes(float cepf, string codigo, int quantidade) { string cd =…
-
2
votes2
answers7771
viewsPass parameter (a list object) from View (List type) to Controller. Asp.NET MVC
I own a view like "List<SimpleUser>" and I want to pass by parameter to my controller the object that is in my foreach, but this arriving null being done as follows: View: @{ ViewBag.Title =…
-
2
votes1
answer849
viewsData conversion in types such as int and double
I’m having trouble making data conversions from a database, for example I perform a query to the bank like this: carteira ca = bc.carteira.FirstOrDefault(obj => obj.cpf == cepf &&…