Questions tagged as 'c#'

1
answer

Why does the compiler require local variables to be initialized and fields not?

The question Why do you usually declare a variable with default value? addresses the issue of whether to initialize or not a variable before using it. However this option becomes mandatory when it comes to a local variable. A field is autom...
asked by 04.07.2017 / 16:29
3
answers

Why can not I declare an attribute using the keyword var?

The var keyword allows me to declare typed variables, and allows the variables to be defined implicitly. Example: var i = 10; The compiler will assume that my variable i is integer type int . So, why does not...
asked by 11.02.2016 / 00:34
3
answers

What are providers? What is the difference between OLE DB and ODBC?

I need to read dbf files. I found a tutorial to read the same where the author uses these two providers. In the code I only saw differences in the connection string. What are these providers? What's the difference between them?     
asked by 25.06.2014 / 17:56
4
answers

Why is using dynamic something to be avoided?

My company works with development, it is a company practice for all codes to be reviewed by another person before they are approved in pull request . Generally my codes have only a few details to change, but this time the reviewer commented...
asked by 10.05.2017 / 18:36
4
answers

Separate repeated values from a list

I have a list like this: [1,1,1,2,2,1,5,3,4,3,4] How to generate a new list with only one value each: [1,2,3,4,5] The first list is List<int> second can come in any type of list.     
asked by 29.03.2017 / 19:55
2
answers

Why are the other types of variables not replaced by dynamic in C #?

I was studying C # and I came across a type of variable dynamic , which from what I understand, it accepts whatever value I enter. Unlike other variables, such as: If I declare as int , I have to type a valor inteiro . If...
asked by 27.10.2016 / 16:49
5
answers

Get national holidays

I am making an application and would like to know if there is any way to get national holidays. For example: Some Google Calendar API where I can get some XML to consume ..     
asked by 25.06.2015 / 20:55
3
answers

How to validate CPF with DataAnnotation on Client and Server?

I need to validate CPF with Data Annotation , and check for duplicity.     
asked by 02.03.2014 / 16:40
6
answers

How to go through an enum?

I need to do the following: Pass a string and go through it and take each letter found and add with its corresponding value, type: a = 1, s = 19 and so on. Well, I made a enum with all values of string , starting with a =...
asked by 06.07.2015 / 12:34
3
answers

Controller returning HTML to View is wrong?

I used this solution because when trying to render a table in a view with many records the user's browser gave Crash, I know it's a not very elegant solution but it was the only solution that came to mind. (In this view I have to load all recor...
asked by 27.08.2014 / 14:07