Questions tagged as 'c#'

2
answers

Does the ListT.ForEach Method exist?

I'm trying to implement the example of this page , but VS2015 (.NET 4.5) says that the ForEach() method does not exist class Program { static void Main() { List<String> names = new List<String>(); na...
asked by 15.11.2015 / 02:57
2
answers

Sorting data with value priority using LINQ

I have a status table with the following values: ID 1 = Ativo ID 2 = Novo ID 3 = Excluido How would you return a list of objects (which have the status object) prioritizing, coming first, those that have Status 2 (New) using LINQ? I wou...
asked by 16.09.2015 / 18:39
2
answers

Return today's date in C # in specific format

My output must be "2015-02-01" I tried to DateTime.Now.ToString("yyyy-m-d") , but it does not put the 0 between days and months.     
asked by 04.04.2016 / 02:31
2
answers

Validation without the "ModelState.isValid"

I have the following scenario: [HttpPost] public PartialViewResult Create(string dados) { var clienteViewModel = DeserializeJson<ClienteViewModel>(dados); if (ModelState.IsValid) { } // Não têm como validar....
asked by 25.11.2016 / 18:52
2
answers

How can I indicate the directory where my assemblies should be found?

My company has a facility that hits the house of gigabytes. We have a set of applications in our installation that share the same libraries. By default, when .NET runs an application, it looks for the assemblies in the same directory where...
asked by 20.02.2017 / 20:02
3
answers

What should I observe when creating a hash code?

Still talking about answer about hash code it was not clear what should be observed to produce good hash codes . I understand that it needs to be a number that does not generate a lot of repetition, but is this enough?     
asked by 22.03.2017 / 13:16
2
answers

Using String.Replace the string remains the same

I have the following string : string tt= "{\"Response\":{\"StatusCode\":200,\"StatusMessage\":\"OK\",\"Content\":{\"family\":{\"codigo\":14,\"descricao\":\"Cal\u00e7a\",\"frontoffice\":1,\"posicaofront\":31,\"posicaoprint\":26,\"fundo\":\"#c0...
asked by 17.02.2017 / 14:36
2
answers

How does an anonymous type return?

I have a method that should return a collection of anonymous objects: /*Aqui deveria ser o tipo anonimo "AnonymousType"*/ [AnonymousType] ListarAnonimo() { //Especifica um "template" para o tipo retornado. var lista = new[] {...
asked by 11.02.2017 / 22:12
2
answers

Entity Framework | Double property that allows null

My property allows values double and values null . In the SQL Server Database it is set to decimal(18, 2) . But when seto some value (ex: 5.00 ), it gives the error below. Error:    The 'Valuation' property...
asked by 29.03.2017 / 23:15
1
answer

Doubt with EntityFramework CodeFirst

I'm starting in the Entity Framework and am having a question regarding CodeFirst . Why do I have to use as virtual some properties like the example below? [Table("Grupo")] public class Grupo { public int ID { get; set; } [Required(Erro...
asked by 11.08.2015 / 23:25