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
-
7
votes1
answer2514
viewsAccess to the shipment file boleto . NET
I am using the billet . NET to generate billets in my application. The ticket is generated, but how do I process the shipment file? This file is saved somewhere in the application? I took the…
c#asked 8 years, 2 months ago Raul Peres de Góes 103 -
7
votes1
answer1263
viewsApp.config how to use`Connectionstring` encrypted
In my app.config I have a section that for my String connecting: </configSections> <connectionStrings> <add name="Azure.Onee"…
-
7
votes3
answers190
viewsConsole, Windows Forms or MVC what’s the fastest for heavy loads?
I’m developing a program that will basically have the following cycle: Database query(some milliseconds) For each record will perform the following process: Início | Parse de um XML web (alguns…
-
7
votes1
answer177
viewsGuid.Parse() or new Guid()?
What’s the main difference between using the options Guid.Parse() or new Guid() to convert a string in a Guid? And which of the two approaches would be best used? var usuarioId = new…
-
7
votes1
answer129
viewsHow to map an image attribute by Fluent API?
I would like to know how to map an attribute of the type image of SqlServer by the Fluent API. In my bank I have the following table: CREATE TABLE [dbo].[ProdutoFotoERP]( [ProdutoFotoID] [int] NOT…
-
7
votes2
answers808
viewsHow to save program settings, database or configuration file?
In my application, the admin user, can make some settings, for example: Configure if you want to use specific product templates, or stay open for the end user to type. Configure if you want to use…
-
7
votes2
answers961
viewsTransactionscopeoption what is the difference between the options?
I was doing some research on the options for Transactionscope and found the following settings: Required A transaction is required for scope. If it already exists, it uses an environment…
-
7
votes2
answers613
viewsCreate shortcut of type 'prop' or 'propfull' in Visual Studio
I would like to create within Visual Studio a shortcut of the type prop or propfull to automatically create a code snippet. the prop + TAB + TAB public int MyProperty { get; set; } the propfull +…
-
7
votes1
answer764
viewsStructure/Organization Project C#
I have a project that I am developing in layers, so far I have the following: Access to data, presentation, business and transfer objects. The doubt is as follows: Example: I have one form to…
-
7
votes3
answers312
viewsTransform a string into multiple substrings whose contents are between apostrophes
I am creating a program in C# that reads a text file and one of the lines of that file has the following format: 'Column 1' 'Column 2' 'Column 3' I want to turn that line into one array of strings…
-
7
votes1
answer1102
viewsPrint window, save PDF Selenium Webdriver
After developing a web page, I am developing the automated testing of this one. I am using Selenium Webdriver com for . NET. After clicking the print button, the popup to choose the printer or…
-
7
votes2
answers512
viewsSort Datetime field only by Date part
I have a property of an entity that’s like DateTime? and in SQL Server is of the type datetime also. I need to make a query that sorts by date, but without considering the time, because in this…
-
7
votes7
answers1103
viewsRemove part of string until nth occurrence of a character
I have a string that always returns in any of these formats: "0001>0002>0003>0004>0005" "abcdef>ghi>jkl>mnopqr>stuvx" Always has the character > dividing something.…
-
7
votes1
answer430
viewsUsing synchronous methods together with asynchrons
For development reasons, I needed to create a call to an asynchronous method in a synchronous method, but when publishing my project on the server, it is indefinitely running. Asynchronous method…
-
7
votes1
answer170
viewsDoes DDD restrict code writing based on the client’s language?
My little knowledge about DDD has been subpoenaed and would like to know more about. The DDD restricts code writing based on the client’s language because of the ubiquitous language?
java c# software-engineering software-architecture dddasked 5 years, 7 months ago Thiago Cunha 1,356 -
7
votes4
answers2085
viewsDoes the date conversion always remain in en-BR?
I’m trying to convert a date in Asp.Net MVC to yyyy-MM-dd, what happens is that always when I convert and display this date it gets dd/MM/yyyy and I don’t know why it happens. How to solve this?…
-
7
votes1
answer1804
viewsThe Entity or Complex type '*' cannot be constructed in a LINQ to Entities query
I can’t do this? public List<Filial> GetAll() { //Mostra todos os registros incluindo os desativados para os Administradores var ret = _db.Filiais.AsNoTracking() .Where(e => e.Visible)…
-
7
votes1
answer2211
viewsIs there a module function of a number in C#?
Example : module of -1 (|-1| = 1). I’ve done some research on the internet but all I think is the division module (%). I am trying to circumvent the common way of passing a negative number to a…
-
7
votes2
answers142
viewsWhat does byte* mean?
I’m studying cryptography and I took an example in AES. In the code is this byte* and even *variavel and I couldn’t understand what it meant. This is the block that uses this, quoted above: byte*…
-
7
votes2
answers116
viewsWhat happens when we assign the default value to objects?
Example: public Carro Metodo(string marca) { Carro carro = default; if(!string.IsNullOrEmpty(marca)) { carro.Marca = marca } return carro; } Studying on the Internet, I realized that some objects…
-
7
votes2
answers930
viewsUnderstanding the documents of a SOAP web service
I am working with a system that offers integration through web service, more precisely SOAP. He provides me with some Urls, which, from what I understand, provide access, describe and document the…
-
7
votes3
answers227
viewsEF Core - Partitioning Filter
I am working in a database that has the following feature, 90% a clustered index that integrates two columns.: FilialID and DataCriacao. These tables are partitioned by FilialID, the simple creation…
-
7
votes1
answer352
viewsHow to allocate an immense amount of memory?
I created an Onfly encryption algorithm that encrypts bytes without the need to copy them to a new copy of those same bytes. This is both to encrypt and to decrypt these byte lists. As in the scheme…
-
7
votes1
answer542
viewsDifference between Absolute Expiration and Sliding Expiration
I am doing a POC with generic cache in C# and followed a model that shows Absolute Expiration and Sliding Expiration. Some could explain these concepts better to me? //This is for Absolute…
-
7
votes3
answers6315
viewsHow to make an "Insert" with Dapper using a class?
I’m testing Dapper and when I try to use a class I found the error: Must declare the scalar variable Follows the code: public class Teste { public int id; public string nome; public int idade; }…
-
7
votes1
answer296
viewsC# - Maintenance of Classes generated from xsd file
I’m developing an application that uses classes generated from xsd files made available by the IRS with the xsd.exe. I use them to serialize xml files from the objects of these classes after…
-
7
votes2
answers684
viewsUse of interfaces in domain classes?
The project analyst I’m working on as a C# programmer vigorously defends the concept of SOLID in development. And it says that one of the requirements to use it is to have interfaces for everything.…
-
7
votes2
answers957
viewsWhat is the way to truncate a string in Csharp?
I have a scenario where I have set the maximum size of a field. I want to cut that amount to the limit. I am doing this through the Substring, but returns an error when I have a character of smaller…
-
7
votes2
answers195
viewsLINQ query with sum
I have the following appointment at LINQ var dados = _db.Contratos .Where(a => a.Adesoes.Any(b => b.Pago)) .Select(a => new { Contrato = a.Numero, ValorTASenior = a.Adesoes.Where(b =>…
-
7
votes4
answers1976
viewsRemove numbers at the end of a Regex string C#
I have a string that contains the name of some records. Examples : string nome = "MARIA APARECIDA DE SOUZA MOURA 636598241"; string nome = "MARIA APARECIDA DE SOUZA MOURA 2018"; I would like to…
-
7
votes2
answers1093
viewsReplace empty or blank letter, something like Replace("letters","")
There is a field in the database A1_ZTEL he is varchar(15). This way each user entered record of all forms, with bar, point, comma and letter. Now I need to ride a form and read this field from…
-
7
votes1
answer424
viewsWhat is the difference between using normal methods and Action or Func?
public Action<string> Escrever = (texto) => { Console.WriteLine(texto); }; Might call it that Escrever.Invoke("Algum texto aqui dentro"); VS public string Escrever(string texto) {…
-
7
votes2
answers138
viewsCombobox is not being filled in by the Items I want
I have a Combobox filled out from a list created with information obtained from a txt file. But instead of being filled in with the file information it is getting inside it ----->…
-
7
votes1
answer773
viewsHow to map two LIST properties using the Automapper
Registernewpessoacommand class public class RegisterNewPessoaCommand { public RegisterNewPessoaCommand(PessoaNatureza pessoaNatureza, PessoaFisica pessoaFisica, PessoaJuridica pessoaJuridica,…
-
7
votes4
answers1423
viewsHow to build custom queries using Entity Framework?
I have an SQL Server database that is accessed via ORM Entity Framework Core, where access to a collection of products, these products are filtered through a DTO that has the terms of the search,…
-
7
votes2
answers173
viewsSearch range of numbers (string type) with Expression Lambda?
I have this data model and I don’t know how to do the instruction lambda: public class CidadeAbrangencia { [Key] public int CidadeAbrangencia_Id { get; set; } public string CEPInicial { get; set; }…
-
7
votes1
answer521
viewsHow to correctly multiply the decimal type in C#?
I’m multiplying monetary values in C#, and for that I’m using the type decimal to store these values. I have noticed that in it there is a method called Multiply(), which receives two values and…
-
7
votes1
answer177
viewsCreate a program that draws 6 numbers and shows how many times it was drawn
I’m making a program that draws 6 numbers (1 to 6) 1 million times and in the end shows how many times was drawn, but I have a doubt in the code, I’m optimizing in vectors not to use if, but in the…
-
7
votes2
answers138
viewsWhat is the Enumerable Zip in . NET?
I was making a code to combine two lists, and looking to improve discovered the method Zip of the interface IEnumerable. At first I thought it was some algorithm to "zip" a list/array/etc., but I…
-
7
votes1
answer480
viewsSleepy barber problem with traffic lights
I found this code online while studying and I couldn’t understand two things: What the traffic light "seatbelt" does? Why isn’t the barber checking the waiting room after finishing a cut? (It goes…
-
7
votes1
answer113
viewsIs there a difference between using discard or ignoring the value returned by a method?
I have a method similar to the below: public bool FazerAlgoERetornarSeSucesso() => true; And at some point, I need to call this method, but I don’t care about the result. Normally I would do…
-
6
votes2
answers2592
viewsHow to optimize an image for web?
On my website someone uploads an image (e.g., 800x600). I would like to save this image in a folder but reducing the disk size as much as possible without losing much quality. How can I do that?…
-
6
votes1
answer3199
viewsWhat does <T> mean in . NET?
I’m working on a project and I saw a lot of code like this public class ExemploCollection<T> { ... } And I don’t understand what this <T> means. What’s the name of it, what am I looking…
-
6
votes1
answer681
viewsLetter after a number, what is this called?
What’s the name of it? double d1 = 0d; decimal d2 = 0L; float d3 = 0f; And where can I find a reference of the characters I can use? If I want to make one cast of 0 for short, there is some letter…
-
6
votes1
answer678
viewsRead SMS history log on iPhone using Xamarin
I need to read the SMS history log sent/received on iPhone, and your time spent on each shipment. I don’t know how to do it and I couldn’t find any material in Portuguese about it. Can anyone help…
-
6
votes1
answer236
viewsBinding Facebook SDK 3.6 for Android
In my project with Xamarin, I need to use the Binding from Facebook SDK for Android version 3.6. However, I could only find the Binding of version 3.0, outdated. Does anyone know where I can find…
-
6
votes1
answer674
viewsHow to define the culture in a WCF Webservice?
I have a plea WCF rotating in the IIS where the server language/culture is all defined in English. There is no possibility for me to change the server settings so that I could change the culture or…
-
6
votes3
answers838
viewsCustom tool Warning: Cannot import wsdl:portType
I can’t use the ServiceReference after successfully importing. After performing the import, write the class and use your methods in the build occur the Warnings: Warning 1 Custom tool warning:…
-
6
votes7
answers2949
viewsHow to use multiple SQL commands (in the case delete on ORACLE) in one line only on C#?
I made a command because of Foreign Keys, only to plug hole, but it is not working for an invalid character error, I believe it is the ";". I know I’m doing this the wrong way, so I accept…
-
6
votes2
answers4039
viewsWhy use Bytes instead of Image? What is the best practice?
I would like to know why to use the data type Bytes instead of using one’s own Image. If the SQL Server database has the Image data type, then it should be easier and more practical to enter in mode…