Questions tagged as 'c#'

2
answers

Create Fibonacci in a linear function with delegate

Using a list for Delegate (I learned that this is called a linear function, is that right?) I decrement the list so it gets its values, but I can not do a simple arithmetic operation with "X", because I have a list and "X" happens to be this l...
asked by 09.07.2015 / 14:23
2
answers

Difference cast using "as" and "type cast"

A question about casting in C #, I see in many sources using cast in the following ways. What's the difference between one and the other when using one way or another? public interface InterfaceTeste { int Id { get; set; } } public...
asked by 23.03.2018 / 20:28
2
answers

What is the purpose of the GetHashCode () method?

I am using Resharper to automate overwriting of the Equals method and the == operator. One of the methods the tool overwritten is GetHashCode : public override int GetHashCode() { unchecked { return (Id.GetH...
asked by 20.03.2017 / 14:14
2
answers

Generate random CPF in C #

I need a generic class to generate valid CPF to send value to fields with selenium webdriver. Does anyone have the code? Thank you.     
asked by 24.09.2014 / 02:45
4
answers

Dynamically check which attributes of a Model have changed?

I'm developing an ASP.NET MVC 4 application and need to save the log of every change made to a Model object. Is there any native method or implementation already known that does this? Example: public class Pessoa { public int? Id { ge...
asked by 14.08.2014 / 20:14
4
answers

How do I execute a method at the end of each method of my C #

You have a parent class and a daughter, and would like to execute a particular method, such as an event, always at the end of each method call for the child classes. How can I do it?     
asked by 23.06.2014 / 13:40
1
answer

Load Combobox from a List

I am trying to load items into a ComboBox from a List<> , it worked fine however, later I would need to get the code for the selected item, but it is not working. The code to load ComboBox is this: private void frm...
asked by 14.08.2016 / 17:51
1
answer

C # IF Simplification

I have this code, and I have been looking for a way to simplify it using a ternary operator, but I can not because it says I can not use decimal in string: decimal per; if (nud_qtPedida.Value != 0) per = nud_qtFornecida.Value * 100 / nud_qt...
asked by 20.05.2016 / 11:28
2
answers

Search for files by extension

In a Windows Forms application I would like to know how to fetch all files that exist and contain the word teste in the file extension. For example, opening a folder in Windows and typing *.teste* into the search field will return...
asked by 04.05.2018 / 19:54
1
answer

How to implement AutoMapper 5.0.2

I set up a project a while back, as follows, A class named AutoMapperConfig as follows: public class AutoMapperConfig { public static void RegisterMappings() { Mapper.Initialize(x => { x.AddProfile<D...
asked by 28.07.2016 / 05:10