Click here to Skip to main content
15,890,506 members
Home / Discussions / C#
   

C#

 
QuestionVenue booking code in vb.net Pin
masosha29-Aug-08 8:35
masosha29-Aug-08 8:35 
AnswerRe: Venue booking code in vb.net Pin
Pete O'Hanlon29-Aug-08 8:38
mvePete O'Hanlon29-Aug-08 8:38 
GeneralRe: Venue booking code in vb.net Pin
Ashfield29-Aug-08 9:02
Ashfield29-Aug-08 9:02 
AnswerRe: Venue booking code in vb.net Pin
Expert Coming29-Aug-08 9:09
Expert Coming29-Aug-08 9:09 
GeneralRe: Venue booking code in vb.net Pin
Verghese29-Aug-08 10:12
Verghese29-Aug-08 10:12 
GeneralRe: Venue booking code in vb.net Pin
Expert Coming29-Aug-08 10:32
Expert Coming29-Aug-08 10:32 
AnswerRe: Venue booking code in vb.net Pin
Wendelius29-Aug-08 10:31
mentorWendelius29-Aug-08 10:31 
QuestionCast Question Pin
Kevin Marois29-Aug-08 8:06
professionalKevin Marois29-Aug-08 8:06 
I have created a class called Book:
public class Book
{
    public int iBookId = 0;
    public String sAuthor = "";
}


Next I load instances of the Book class into an ArrayList. I then have an overloaded method to search for a book by Name or Id.
private static Book _FindBook(int iBookIdToFind, String sNameToFind)
{
	// Define variables
	Book bookReturn = null;			// Holds the book to be returned
	Book bookArrayBook = null;		// Holds the book from each araray element
	int iTotalBooks = books.Count;	// The length of the array
	
	// Loop once for each array element
	for (int iBook = 0; iBook < iTotalBooks; iBook++)
	{
		// Extract a book from the array
		bookArrayBook = books[iBook];
		
		// If a book Id was passed in...
		if (iBookIdToFind != 0)
		{
			// If the Id passed in matches the Id on the book from
			// the array element...
			if (bookArrayBook.iBookId == iBookIdToFind)
			{
				// Store the array element's book to the return variable
				// and exit the loop
				bookReturn = bookArrayBook;
				break;
			}
		}
		else
		
			// If the name passed in matches the name on the book from
			// the array element...
			if (bookArrayBook.sAuthor.ToLower() == sNameToFind.ToLower())
		{
			// Store the array element's book to the return variable
			// and exit the loop
			bookReturn = bookArrayBook;
			break;
		}
	}
	
	return bookReturn;
}


On this line
bookArrayBook = books[iBook];


I get the error "Cannot implicitly convert type 'object' to 'Book'".

I don't understand this. The object in the collection is already a book.

Anyone?

Everything makes sense in someone's mind

AnswerRe: Cast Question Pin
DaveyM6929-Aug-08 8:15
professionalDaveyM6929-Aug-08 8:15 
GeneralRe: Cast Question Pin
Kevin Marois29-Aug-08 8:30
professionalKevin Marois29-Aug-08 8:30 
AnswerRe: Cast Question Pin
Expert Coming29-Aug-08 8:21
Expert Coming29-Aug-08 8:21 
GeneralRe: Cast Question Pin
Kevin Marois29-Aug-08 8:28
professionalKevin Marois29-Aug-08 8:28 
GeneralRe: Cast Question Pin
Expert Coming29-Aug-08 8:34
Expert Coming29-Aug-08 8:34 
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 
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 

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.