Questions tagged as 'c#'

1
answer

Bhaskara formula in C # with VS 2017

Personal Talk! I'm using Visual Studio to learn C #, I created a button that when clicked should show the result of a Bhaskara formula. But everything that appears on the screen when testing comes down to "NaN" using System; using System.Colle...
asked by 21.07.2018 / 15:47
1
answer

How to split a file line without using Substrings in C #?

I have created a file where I save line-by-line data as morada|nome|telefone|nif , meaning each variable stored in the file is divided by | . I remember there being a method of dividing this line into 4 to add to a dataGridView wi...
asked by 27.09.2017 / 10:39
1
answer

How to return a list from each chapter?

Following text file: @MATEUS (1) 1 Livro da genealogia de Jesus Cristo, filho de Davi, filho de Abraão. 2 A Abraão nasceu Isaque; a Isaque nasceu Jacó; a Jacó nasceram Judá e seus irmãos; 3 a Judá nasceram, de Tamar, Farés e Zará; a Farés nasc...
asked by 13.10.2017 / 16:54
2
answers

Return last record from table

I'm trying to make a method that returns the last record of the table but gives error:    "Coditem" operation failed public int UltimoItem() { con = conexao.obterConexao(); try { cmd = new SqlComm...
asked by 04.10.2017 / 21:48
2
answers

Regular expression for Telephones with numbers only and C # DDD [duplicate]

I would like an help to create a regular expression in C # that validates number of phones with DDD but without points and dashes, only numbers. It would be in the format XX12345678 and XX 123456789.     
asked by 24.10.2017 / 14:54
1
answer

ConnectionStrings: Write in app.config or windows registry?

My question is the best way to keep ConnectionString of my system on disk to be read as needed, ie what is the best way to do this by writing it to the file app.config , or writing to record of Windows ? What are the a...
asked by 24.01.2017 / 23:32
1
answer

How to set the Index of a List to start at 1 instead of 0 when populated

Whenever I populate a list in C #, as in the example below, as I add items, they are arranged starting from position 0 in index . If I add 5 items to my list, I will have 0, 1, 2, 3, and 4 positions. I need to make index start with 1 and get i...
asked by 26.10.2018 / 00:43
1
answer

Load C # combobox from another in Load ()

It's been so long since I was working with WinForms that I'm letting something go. In Load from my Form I call this method below: private void CarregarEstados() { cboEstado.DataSource = Listas.ListaEstados(); cboEstado.DisplayMember =...
asked by 19.10.2018 / 15:38
2
answers

Randomly generated list

I want to generate a list of cars with random characteristics of brand, model, color and year. These values are stored in a car list. The problem is that at the time of doing the loop that calls the gerarCarro() function, which adds ran...
asked by 04.08.2017 / 02:07
3
answers

Create a way to not repeat my code [closed]

How can I create a way to simplify the code below so that some things do not happen again? I'd like my " Generate User " code not to repeat over IF . How do I proceed? if (txtNome.Text == ""){ MessageBox.Show("Digite o nome do usu...
asked by 14.09.2017 / 20:19