What the meaning of  "if (MaterialID.IndexOf("%")>-1)"

Rama Tito
Rama Tito used Ask the Experts™
on
Please do elaborate the meaning of  "if (MaterialID.IndexOf("%")>-1)". What means of indication of "%" and  -1 as well.
if (MaterialID.IndexOf("%")>-1)
				{	
					strCommand ="select top 2000  ID,OrderNumber,PartNumber,Weight,DONumber,MaterialType,Receiveddate,MaterialNumber as MaterialCode,supplier,VesselName,StorageLocation,Status,ReceivedBy,ApprovedBy,Remarks   from rawMaterial where  " + dateCondition +  " and ID like '" + MaterialID +"'and materialtype not like '%sheet%' order by " + sortType;
				}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
if % is not found in MaterialID IndexOf return -1
else % can be the first char in the string or have a greater postion (index)

the % char is a wildcard caractere when you sue it with LIKE, check argument on this page : http://msdn.microsoft.com/en-us/library/ms179859.aspx
Commented:
it finds in the MaterialID for some data if nothing in that it returns -1. to test MaterialID have something use this.
Rama TitoProgrammer

Author

Commented:
Is that returns -1 if reach end of file or database.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial