Jump to content
  • Advertisement
Sign in to follow this  
jor1980

c# array.find

This topic is 2852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!