Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: Question about Interfaces Pin
MarkB77729-Aug-08 18:36
MarkB77729-Aug-08 18:36 
GeneralRe: Question about Interfaces Pin
Scott Dorman29-Aug-08 19:15
professionalScott Dorman29-Aug-08 19:15 
QuestionMoving from VSWD Express 2008 to VS2008, Namespace problem Pin
Vodstok29-Aug-08 13:01
Vodstok29-Aug-08 13:01 
QuestionPointer help Pin
jacobjordan29-Aug-08 12:54
jacobjordan29-Aug-08 12:54 
AnswerRe: Pointer help Pin
Mark Salsbery29-Aug-08 14:03
Mark Salsbery29-Aug-08 14:03 
AnswerRe: Pointer help Pin
Guffa30-Aug-08 0:08
Guffa30-Aug-08 0:08 
QuestionCuror Pin
netJP12L29-Aug-08 9:12
netJP12L29-Aug-08 9:12 
AnswerRe: Curor Pin
Wendelius29-Aug-08 9:38
mentorWendelius29-Aug-08 9:38 
QuestionGet list of all fields referenced from RDLC XML file Pin
AndrusM29-Aug-08 9:05
AndrusM29-Aug-08 9:05 
AnswerRe: Get list of all fields referenced from RDLC XML file Pin
Wendelius29-Aug-08 9:17
mentorWendelius29-Aug-08 9:17 
GeneralRe: Get list of all fields referenced from RDLC XML file Pin
AndrusM29-Aug-08 9:31
AndrusM29-Aug-08 9:31 
GeneralRe: Get list of all fields referenced from RDLC XML file Pin
Wendelius29-Aug-08 9:59
mentorWendelius29-Aug-08 9:59 
GeneralRe: Get list of all fields referenced from RDLC XML file Pin
AndrusM30-Aug-08 6:59
AndrusM30-Aug-08 6:59 
GeneralRe: Get list of all fields referenced from RDLC XML file Pin
Wendelius30-Aug-08 7:10
mentorWendelius30-Aug-08 7:10 
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 

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.