Questions tagged as 'c#'

2
answers

How to store a Listobject in a database?

I'm working on a C # project where I have the following situation. I have a class that represents a player: class Player { int ID; string Name; } and one that represents a team: class Team { int ID, string Name; List<...
asked by 27.07.2016 / 18:31
3
answers

List best practice, start with fixed capacity or start without limit?

I have a scenario where I will receive a list, or an array, or any other data type of the database where I can know the size of my list before creating it, what is the advantage between newList and the newList2 in my code below? Is there any...
asked by 14.03.2018 / 11:12
3
answers

Performance "where in foreach vs if"

Which of the cases would perform best? var chaves = new list<string>(); foreach(var item in lista) { if(!string.IsNullOrEmpty(item.Chave)) { chaves.Add(item.Chave); } } Or listaValida = lista.Where(x => !string.IsN...
asked by 13.04.2017 / 17:13
2
answers

How to get all the constants of a class?

My project has a helper class with multiple constants representing pre-defined roles . public static class RolesHelper { public const string ModuloUsuarios = "Usuarios"; public const string ModuloMenus = "Menus"; public const st...
asked by 07.02.2017 / 18:37
5
answers

How to embed CSS in HTML tags?

I have a CSS file containing the following code. .texto{ Color: Red; } I have the HTML file with these tags : <html> <body> <span class="texto">TEXTO 1<span> <span class="texto">TEXTO 2<span> <sp...
asked by 05.11.2014 / 19:54
1
answer

How to return to the default settings of the Visual Studio editor?

I was using ReSharper in evaluation period and after testing time I did not want to purchase and then uninstalled by Control Panel Visual Studio But the default settings of the Visual Studio editor did not return, such as the re...
asked by 15.08.2014 / 14:34
2
answers

How to use C # quotes?

I'm starting to program in C # and I'm having some difficulties with the quotation marks when I need to paste some text. In Python I could use the triple quotation marks to paste some text that there was a line break, already in C # I have no id...
asked by 15.11.2018 / 13:43
2
answers

How to make a switch in C #?

I see a lot of people saying it's wrong to switch in the code because it ends up weighing and it's ugly. Is it correct the way I'm using it and what would be an alternative to using it? Fill in the code for if / else ?...
asked by 29.11.2018 / 12:06
3
answers

Get the last N characters of a string

I have string which is actually a phone number . But a phone number might have some formats like: +55 34 98989898 34 989898 989898 The constant is that always the last 8 numbers are the phone numbers, I wanted to know how I separa...
asked by 08.10.2015 / 21:23
2
answers

How to convert a nullable int to common int

I have a method that receives an integer that can be null , in case some method executions happen, but when I use this same variable in a place that uses int that can not be null, it appears that the overload is incorrect....
asked by 15.05.2017 / 19:51