Why error is there

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Why I'm sometimes getting error from this code:

C#:
var r = new Random();
int rand = r.Next(1, 12);
System.Threading.Thread.Sleep(1000);
if(rand == 1) project.Profile.Login = project.Profile.Surname + project.Profile.Age;
else if(rand == 2) project.Profile.Login = project.Profile.Login;
else if(rand == 3) project.Profile.Login = project.Profile.Name + project.Profile.Age + project.Profile.Surname;
else if(rand == 4) project.Profile.Login = project.Profile.Name + "." + project.Profile.Surname;
else if(rand == 5) project.Profile.Login = project.Profile.Name + project.Profile.Surname + project.Profile.Age;
else if(rand == 6) project.Profile.Login = project.Profile.CurrentRegion + project.Profile.Age;
else if(rand == 7) project.Profile.Login = project.Profile.Interest + project.Profile.Age;
else if(rand == 8) project.Profile.Login = project.Profile.NickName;
else if(rand == 9) project.Profile.Login = project.Profile.Name + project.Profile.ZipCode;
else if(rand == 10) project.Profile.Login = project.Profile.Name + project.Profile.BornYear;
else if(rand == 11) project.Profile.Login = project.Profile.Surname + project.Profile.BornYear;
Error message: Object reference not set to an instance of an object.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 715
Баллы
113
Works fine in PM in latest build :bw:
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 715
Баллы
113
Profile.Interest ?
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Looks like really this will make error, but check there is such string in c#. You can define project.Profile.Interest but when you try to execute then there is this error Object reference not set to an instance of an object.

Means that need to delete it from possible options...
 

Кто просматривает тему: (Всего: 2, Пользователи: 0, Гости: 2)