Skip to main content
gamedev.net
🔒 Locked

c# array.find

Started by jor1980 Sep 29, 2010 at 10:01 AM 3 replies 1.8k views
Original Post
jor1980
jor1980
Hi to all, i have created a class named subfileInfo:
 public class SubFileINfo    {       public string Name;       public UInt32 StartOffset;       public UInt32 Length;    }


and i have an arrary of subfileInfo
SubFileInfo[] SubFileArray;



now i need to find in my SubFileArray the subfilesinfo that has in their names the string contained in textbox1.text

I am trying to do this wit Array.find but i am very confused i don´t achive to do it, How can i search for the subfilesinfo which contains into their name the substring textbox1.text
Gage64
Gage64
I think this should work:

SubFileINfo info = Array.Find(SubFileArray, sfi => sfi.Name.Contains(textbox1.text));


The => syntex is called a lambda expression, you can google that for more info.

The MSDN page shows an example without lambda expressions, which might be easier to understand.
jor1980
jor1980
Quote:
Original post by Gage64
I think this should work:

SubFileINfo info = Array.Find(SubFileArray, sfi => sfi.Name.Contains(textbox1.text));


The => syntex is called a lambda expression, you can google that for more info.

The MSDN page shows an example without lambda expressions, which might be easier to understand.


Thank´s for the help, i have another question, normally that will find more than one elementswhich have the substring textbox1.tex in their name, could i make the operation you wrote me saving the results into a FileInfo array?
jor1980
jor1980
Thank´s for all you have help me a lot

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.