First of all, sorry if I make mistakes with english, it's not my monthertongue.
I'm developing in C#, and I have a problem I don't know how to solve.
"An unhandled exception of type 'System.NullReferenceException' occurred in AccountManagement.exe"
"Additional information: La référence d'objet n'est pas définie à une instance d'un objet." Translation --> Object reference is not set to an object
Here is the code:
private List<String> MyLines;
public List<String> GetMyLines()
{
return MyLines;
}
public void SetOneLines(string LineToInsert) //Insert juste un élément dans ma liste
{
MyLines.Add(LineToInsert); !!!!! Where the error occurs !!!!
}
This function is called here:
public void Identification()
{
Console.WriteLine("Indiquez votre nom et votre prénom");
string UserLastNameTemp = Console.ReadLine();
string UserNameTemp = Console.ReadLine();
using (StreamReader ReadFileUser = new StreamReader("C:\\Users\\XXX\\Desktop\\user.txt"))
{
string Line;
while ((Line = ReadFileUser.ReadLine()) != null)
{
Console.WriteLine(Line);
SetOneLines(Line);
}
}
I already faced this type of error, but I must admit I don't know how to proceed here, cause I don't even know why this error is :D
Could someone give me a tip?