It gets the last 4 characters from txtCardNo (without leading or txtCardNo spaces), but it would be better if it were like this:
var result = txtCardNo.Text.Trim(); result = result.Substring(result.Length - 4);
EDIT:
Also note that this will result in an error if the cropped string has less than 4 characters. You could handle something like this:
var result = txtCardNo.Text.Trim(); if (result.Length >=4) result = result.Substring(result.Length - 4); else
source share