✅ Possible bug in ternary operator when incrementing in razorpages?
inside some .cshtml:
@{
int a;
int k;
if(Model.SomeArray != null)
{
a = Model.SomeArray[0].SomeIndex;
}
for(int i=0; i<Model.SomeOtherArray.Length; i++)
{
if(i==a)
{
//do somework
k = (k+1 < Model.SomeArray.Length) ? k++ : k;
}
}
}
correct me if im wrong but k should increment here and then be saved? or is the ternary operator scope localized and the parameter get incremented in another scope and the obj ref then dropped, meaning that the work is lost?
in razor pages k++, or even k=k++; doesnt update the object. k=k+1 works though. This should be a bug right?
@{
int a;
int k;
if(Model.SomeArray != null)
{
a = Model.SomeArray[0].SomeIndex;
}
for(int i=0; i<Model.SomeOtherArray.Length; i++)
{
if(i==a)
{
//do somework
k = (k+1 < Model.SomeArray.Length) ? k++ : k;
}
}
}
correct me if im wrong but k should increment here and then be saved? or is the ternary operator scope localized and the parameter get incremented in another scope and the obj ref then dropped, meaning that the work is lost?
in razor pages k++, or even k=k++; doesnt update the object. k=k+1 works though. This should be a bug right?