Questions tagged as 'c#'

1
answer

Parameter of any type in method

I am building a method and would like it to extend to any type. For now I am using string but I would like it to work for int , float , double and datetime . public static bool isNotNull(string AnyTypeValue) //...
asked by 07.04.2015 / 20:01
1
answer

Doubt between Any and All in a lambda expression in a list

In a list, I have 12 records (hypothetical) and there is a field called ValorCampoFlag , where this field receives 1 or null , for example. If I do a validation on it and the result if there is at least one with a value of 1, should...
asked by 12.02.2015 / 13:30
2
answers

Why an anonymous method can not be assigned to a var or dynamic?

The following code: var mostra = delegate(string x) { Console.WriteLine(x); }; mostra("teste"); Should .Net not identify var as Action<string> ? And the same pro dynamic ?     
asked by 22.03.2015 / 04:36
1
answer

How to determine the character's level by gaining experience?

I created this calculation based on multiples below to determine how much the character will need to have experience to level up. float NeededExperience(int level, float experienceRatio = 100F) { float neededExperience = ((level - 1) * exp...
asked by 05.10.2016 / 20:31
2
answers

When to use try catch in layered application?

Let's say I have my layers Controller Business Repository So it is necessary to create this block in the 3 layers or create only in controller ? If I do this does it guarantee that any code that is made inside it will be thrown at...
asked by 22.11.2018 / 17:01
1
answer

What is the need to inform the "Order" parameter in the object of type IndexAnnotation?

I am creating indexes for some columns that will be used in a query with Where() . The intention is to make the search faster. Until then I was creating like this: Property(x => x.Documento) .HasColumnAnnotation(IndexAnnot...
asked by 03.01.2017 / 14:15
2
answers

What is the cleanest and clearest way to validate entities using the Entity Framework

I'm using the Entity Framework for data manipulation. The project is divided into 2, one containing the domain entities and the other Fluent Api mappings). I need a clean and clear way to validate entities without polluting entities with Dat...
asked by 02.02.2017 / 00:00
2
answers

Builders with this, which means

This constructor has this , what does it really mean? public class HelpController : Controller { private const string ErrorViewName = "Error"; public HelpController() : this(GlobalConfiguration.Configuration) { }...
asked by 21.05.2017 / 17:36
1
answer

Good practices with .NET MVC

I have an ASP.NET MVC application and would like to know what are the best practices that microsoft indicates in the organizational question of the solution, using the latest technologies like ASP.NET Identity. Assuming the following scenario...
asked by 21.11.2014 / 20:46
2
answers

Foreach in a CheckList in C #

private void Checked() { foreach (ListViewItem listItem in listView.Items) { if (cb_selectAll.Checked == true) { listItem.Checked = true; } if (cb_selectAll.Checked == false) {...
asked by 04.05.2017 / 17:22