I have this helper method on an MVC View that returns the first name and last name of the user (Windows autheticated application)
@helper AccountName()
{
using (var context = new PrincipalContext(ContextType.Domain))
{
var principal = UserPrincipal.FindByIdentity(context, User.Identity.Name);
@principal.GivenName<text> </text>@principal.Surname
}
}
How can I extract the initials of the user(first letter of first name and first letter of last name)?
I tried with linq:
@AccountName().ToString().Split(' ').Select(x => x[0]).ToArray()
But that results:
System.Char[]
Any help would be appreciated