Questions tagged as '.net'

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

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
2
answers

Declaration of 'var' as field of object

How could I declare a variable var public so I could get the data back. What would be the declaration of these unfilled variants: var tbuscar = ?; var retorno = ?; public bool CarregaProdutosDermaClube(string consult...
asked by 26.05.2017 / 16:53
2
answers

How to add methods to a native class?

How to add functions in a native C # class, in my case, I tried to do in System.Math just as test: public class Math { public static double test(double a) { return a; } } And call it like this: Math.test(10);...
asked by 20.06.2017 / 00:27
2
answers

ToList vs. Typed ToList

I was reviewing some methods of an ASP.NET MVC project and found some cases where only .ToList() is used and others where .ToList<type>() is used (where type is a type of object used in context). Imagine that only with...
asked by 14.03.2017 / 13:07
1
answer

What is the best way to set up a query?

What is the best way to set up a query in C #? Is it advisable to use concatenation with the + operator? For example: query += " WHERE nome LIKE '%" + nome + "%'"; Here is a% w of% that I set as an example to illustrate the situat...
asked by 18.12.2015 / 00:24
2
answers

Remove element from a vector in C # and not leave the vector with a space?

I need to remove an element from a vector with 5 elements, and can not have empty space in the vector. I need to remove by index.     
asked by 11.03.2016 / 00:00
1
answer

Access modifier property C #

I noticed that it is possible to sign the access mode of a property as private: public string Codigo { get; private set; } Or just ignore it: public string Codigo { get; } Is there a difference or some scenario where one of these signa...
asked by 10.04.2016 / 17:29
1
answer

What are Sockets? And how to develop in C #?

I have to develop a socket, but I do not know what it is or how it works! I want to know what it takes to create a socket in C #, I'm using Visual Studio as IDE.     
asked by 20.04.2016 / 01:08