string name = "BLK000012345summary.pdf";
string fileName = "20150929111111zp2zq23BLK000012345summary.pdf";
I have a string name
which I have to find in fileName
, if it exists it should return true otherwise false.
string name = "BLK000012345summary.pdf";
string fileName = "20150929111111zp2zq23BLK000012345summary.pdf";
I have a string name
which I have to find in fileName
, if it exists it should return true otherwise false.
string name = "BLK000012345summary.pdf";
string fileName = "20150929111111zp2zq23BLK000012345summary.pdf";
bool value = fileName.Contains(name);
A simple string.Contains
will do the job:
bool contains = fileName.Contains(name);
It will check if the fileName
contains name
and will return true
if so. Note that Contains
will match case-sensitive. It has to match exactly. If you want to match case insensitive, a regular expression or this post might be helpful, which tells you to use the current culture to do an IndexOf
.