Home Repetative "If statements" save and reuse results
Reply: 0

Repetative "If statements" save and reuse results

user898
1#
user898 Published in April 22, 2018, 6:07 pm

I am in Visual Studio view of the MVC (razor code). I have the same bool "if statemant" being used several times in different area's of the code. I have been told that I could save the results of the first if statement and reuse the results so I don't have to write the "if statement" several times over.

How do I save the results of the first if statement and reuse the results below?

var IsManager = someRole;
var IsTeamLead= someOtherRole;

if(IsManager || ITeamLead)
{
 //Veiew this resticted content on the application;
}

//Code;
//Code;

if(IsManager || IsTeamLead)
{
 //Veiew more resticted content on the application;
}

//Little more code;
//Little more Code;

if(IsManager || Is TeamLead)
{
 //Veiew this content too;
}

//Little more code
//Little more code
//Little more code

if(IsManager || IsTeamLead)
{
 //Veiew this content;
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304888 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO