Click here to Skip to main content
15,891,529 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cast Question Pin
Kevin Marois29-Aug-08 8:43
professionalKevin Marois29-Aug-08 8:43 
GeneralRe: Cast Question Pin
Expert Coming29-Aug-08 8:59
Expert Coming29-Aug-08 8:59 
GeneralRe: Cast Question Pin
Kevin Marois29-Aug-08 9:02
professionalKevin Marois29-Aug-08 9:02 
GeneralRe: Cast Question Pin
Expert Coming29-Aug-08 9:07
Expert Coming29-Aug-08 9:07 
AnswerRe: Cast Question Pin
Guffa29-Aug-08 8:29
Guffa29-Aug-08 8:29 
AnswerRe: Cast Question Pin
Scott Dorman29-Aug-08 8:45
professionalScott Dorman29-Aug-08 8:45 
GeneralRe: Cast Question Pin
Kevin Marois29-Aug-08 8:49
professionalKevin Marois29-Aug-08 8:49 
GeneralRe: Cast Question Pin
Scott Dorman29-Aug-08 8:59
professionalScott Dorman29-Aug-08 8:59 
KMAROIS wrote:
Problem is, I'm stuck with VS 2003 for now


That's too bad. In that case, you should still define two separate overloads for your Find method (one that takes an int and one that takes a string). You can simplify your find code as well:
private static Book Find(int bookId) 
{
   Book foundBook = null;
 
   foreach(Book book in books)
   {
      if (book.iBookId == bookId)
      {
         foundBook = book;
         break;
      }
   }
   return foundBook;
}
 
private static Book Find(string authorName) 
{
   Book foundBook = null;
 
   foreach(Book book in books)
   {
      if (String.CompareOrdinal(book.sAuthor, authorName) == 0)
      {
         foundBook = book;
         break;
      }
   }
   return foundBook;
}
If you don't want to use the foreach, you would need to change this line
bookArrayBook = books[iBook];
to
bookArrayBook = (Book)books[iBook];


Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

AnswerRe: Cast Question Pin
Mbah Dhaim29-Aug-08 13:08
Mbah Dhaim29-Aug-08 13:08 
QuestionReceiving RS232 signals through USB Pin
Calvin Wong29-Aug-08 6:46
Calvin Wong29-Aug-08 6:46 
AnswerRe: Receiving RS232 signals through USB Pin
Dan Neely29-Aug-08 7:00
Dan Neely29-Aug-08 7:00 
AnswerRe: Receiving RS232 signals through USB Pin
Joe Woodbury29-Aug-08 11:47
professionalJoe Woodbury29-Aug-08 11:47 
Questionhow to build my own Outlook? Pin
Jassim Rahma29-Aug-08 5:22
Jassim Rahma29-Aug-08 5:22 
AnswerRe: how to build my own Outlook? Pin
Kevin Marois29-Aug-08 8:02
professionalKevin Marois29-Aug-08 8:02 
AnswerRe: how to build my own Outlook? Pin
Pete O'Hanlon29-Aug-08 8:40
mvePete O'Hanlon29-Aug-08 8:40 
GeneralRe: how to build my own Outlook? Pin
Jassim Rahma29-Aug-08 10:22
Jassim Rahma29-Aug-08 10:22 
GeneralRe: how to build my own Outlook? Pin
Wendelius29-Aug-08 10:37
mentorWendelius29-Aug-08 10:37 
GeneralRe: how to build my own Outlook? Pin
Pete O'Hanlon30-Aug-08 11:14
mvePete O'Hanlon30-Aug-08 11:14 
QuestionInheritance and type casting Pin
Dewald29-Aug-08 4:14
Dewald29-Aug-08 4:14 
AnswerRe: Inheritance and type casting Pin
Scott Dorman29-Aug-08 4:48
professionalScott Dorman29-Aug-08 4:48 
AnswerRe: Inheritance and type casting Pin
Abhishek Sur29-Aug-08 4:50
professionalAbhishek Sur29-Aug-08 4:50 
QuestionAttempted to read or write protected memory. This is often an indication that other memory is corrupt. Pin
Shpendh29-Aug-08 4:10
Shpendh29-Aug-08 4:10 
AnswerRe: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Pin
Pete O'Hanlon29-Aug-08 4:40
mvePete O'Hanlon29-Aug-08 4:40 
GeneralRe: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Pin
Shpendh29-Aug-08 5:08
Shpendh29-Aug-08 5:08 
GeneralRe: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Pin
lisan_al_ghaib29-Aug-08 5:59
lisan_al_ghaib29-Aug-08 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.