ivan rosa
asked on
-Programming: Learning about "classes" ...
Hello Folks,
I'm expanding my knowledge in learning classes in powershell... I have written this basic PS example
this will display the book from book 2 titled like "scott"...
Does anybody have any idea on how can I tell the program to search within all the books and find any "X" Title... I was thinking "foreach" but i'm not sure I could squeeze it in...? or if you have a c# approach that would be great also :)
Thanks in advance!
I'm expanding my knowledge in learning classes in powershell... I have written this basic PS example
class Books {
[string]$title
[string]$author
[int]$pages
}
$books1 = [books]::new()
$books1.title = "Harry Potter"
$books1.author = "JK Rowling"
$books1.pages = 309
$books2 = [books]::new()
$books2.title = "Scott Pilgrim vs. the World"
$books2.author = "Bryan Lee O'Malley"
$books2.pages = 168
$books2 | ? {$_.title -like "*scott*"}
this will display the book from book 2 titled like "scott"...
Does anybody have any idea on how can I tell the program to search within all the books and find any "X" Title... I was thinking "foreach" but i'm not sure I could squeeze it in...? or if you have a c# approach that would be great also :)
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your swift response @oBdA. as usual you are always on point!
Thanks for the tips also as well as @Alfred I appreciate it
Thanks for the tips also as well as @Alfred I appreciate it
please follow this link