public class ChemDB : MonoBehaviour
{
private int i;
void Start ()
{
string[] lines = System.IO.File.ReadAllLines("Assets/Scripts/Data/Database.txt");
int perioada=0,grupa=0,nrAt=0,masa=0,valenta=0,a=0,b=0,c=0,d=0,e=0,f=0,g=0;
string Nume,Simbol,Tip,Stare;
for(i=1;i<=118;i++)
{
Int32.Parse(lines[(i-1)*16],perioada);
Int32.Parse(lines[1+(i-1)*16],grupa);
Int32.Parse(lines[2+(i-1)*16],nrAt);
Nume=lines[3+(i-1)*16];
Simbol=lines[4+(i-1)*16];
Int32.Parse(lines[5+(i-1)*16],masa);
Int32.Parse(lines[6+(i-1)*16],valenta);
Tip=lines[7+(i-1)*16];
Stare=lines[8+(i-1)*16];
Int32.Parse(lines[9+(i-1)*16],a);
Int32.Parse(lines[10+(i-1)*16],b);
Int32.Parse(lines[11+(i-1)*16],c);
Int32.Parse(lines[12+(i-1)*16],d);
Int32.Parse(lines[13+(i-1)*16],e);
Int32.Parse(lines[14+(i-1)*16],f);
Int32.Parse(lines[15+(i-1)*16],g);
}
}
}
I'm using Unity C#.I get thhis error "The best overloaded method match for `int.Parse(string, System.IFormatProvider)' has some invalid arguments." and i don't understand what i'm doing wrong.
Int32.Parse taskes the string as the first parameters, and returns the number as an int.
You are passing the variable to store the int as the second parameter like this:
Int32.Parse(lines[(i-1)*16],perioada);
It should be used like this:
perioada = Int32.Parse(lines[(i-1)*16]);
Thats why you are getting the error, because the second optional parameter is used to define the format of the string passed in the first parameter. But since you are using an int, the types don't match.