this is the first time i work on C# and ASP.NET, i’m reading Beginning ASP.NET 4 in c# 2010 but i never worked with object-oriented programming. (I’m a network admin so i know basic programming).
Still, i can’t get to work a simple program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2 {
class Program {
static void Main(string[] args) {
int i;
string[] nomi = new string[7];
string[] cognomi = new string[7];
for (i = 0; i = 6; i++) {
Console.WriteLine("Inserisci il", i + 1, "° nome");
nomi[i] = (Console.ReadLine);
}
for (i = 0; i = 6; i++) {
Console.WriteLine("Inserisci il", i + 1, "° cognome");
nomi[i] = (Console.ReadLine);
}
for (i = 0; i = 6; i++) {
Console.WriteLine(nomi[i], " ", cognomi[i]);
}
}
}
}
The problem is not in the algorythm but in the declaration part. I can’t show the error log because i have VS in Italian.
Where am i wrong?
It’s tough to help without error messages (maybe you can translate them since you obviously know both languages).
For sure, your
forloop syntax is incorrect. This:Should be:
Take a look at for loop documentation on MSDN.
In addition
Console.ReadLineis a method, not a property: