I have an issue with string manipulation in c#. Please check the follwoing expression :
public static string UNID = ((Thread.CurrentPrincipal as ClaimsPrincipal).Identity as ClaimsIdentity)
.Claims.Single(c => c.ClaimType.Contains("nameidentifier")).Value.Substring( //issue is here
I want to point the value in the substring function for applying the indexOf function on it. I tried this keyword but not working :
public static string UNID = ((Thread.CurrentPrincipal as ClaimsPrincipal).Identity as ClaimsIdentity)
.Claims.Single(c => c.ClaimType.Contains("nameidentifier")).Value.Substring(this.IndexOf('/') + 1);
I know that we can do the same thing by breaking the expression into parts like :
var value = ((Thread.CurrentPrincipal as ClaimsPrincipal).Identity as ClaimsIdentity)
.Claims.Single(c => c.ClaimType.Contains("nameidentifier")).Value;
var UNID = value.Substring(value.IndexOf('/') + 1);
But if there is any solution for this just like i was trying with this keyword. Then please let me know ?
This should work: