BranchState is a class which has the following properties:
- State
- Branch
- AgencyId
- Description
With this code…
var AgencyBranches =
from b in BranchStates
select b.Description.Distinct();
var States =
from s in BranchStates
select s.State.Distinct();
if (AgencyBranches.Count() == 1 && States.Count() == 1)
{
if (States.FirstOrDefault().Tostring() == "CA") /// **This always yields some generic value.**
Response.Redirect("StateCA.aspx");
if (States.FirstOrDefault().Tostring() == "Az") /// **This always yields some generic value.**
Response.Redirect("StateAz.aspx");
}
… States.FirstOrDefault() always yields System.Collections.Generic.List`1[System.Char]
Thanks in advance
This does not do what you think it does, because it’s missing some parentheses:
Here,
Distinctoperates in eachStateproperty value yielding a sequence of characters becauseState(astring) implementsIEnumerable<char>.You probably meant