Click here to Skip to main content
15,919,778 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# help? Pin
Deborah Palmer McCain16-Dec-11 6:35
Deborah Palmer McCain16-Dec-11 6:35 
AnswerRe: C# help? PinPopular
DaveyM6915-Dec-11 9:25
professionalDaveyM6915-Dec-11 9:25 
GeneralRe: C# help? Pin
Luc Pattyn15-Dec-11 19:59
sitebuilderLuc Pattyn15-Dec-11 19:59 
AnswerRe: C# help? Pin
gymmy15-Dec-11 12:31
gymmy15-Dec-11 12:31 
AnswerRe: C# help? Pin
DaveyM6915-Dec-11 13:18
professionalDaveyM6915-Dec-11 13:18 
QuestionC# question? Pin
Brian Reiber15-Dec-11 5:14
Brian Reiber15-Dec-11 5:14 
AnswerRe: C# question? Pin
DaveyM6915-Dec-11 5:32
professionalDaveyM6915-Dec-11 5:32 
AnswerRe: C# question? PinPopular
Pete O'Hanlon15-Dec-11 5:37
mvePete O'Hanlon15-Dec-11 5:37 
Where to start? Well, you haven't initialised your array, so the first line needs to become:
C#
string [,] books = {
Next, you are adding in an integer into each line but it's expecting 2 strings so you should make it:
C#
{"The Time Machine, Science Fiction, By H.G.Wells","3"}, // Note the comman, and not a semi-colon
As you are using an array initializer here, you need to end it with another } because you are adding in multiple items. I've already taken care of the first one for you at the top, so you'd end your initialisation with:
C#
{"The Da Vinci Code, Mystery, By Dan Brown","2"}};
Note that the lists in the array must be separated by commas and not semi-colons.

int book needs to be terminated with a semi-colon as in:
C#
int book;
Beyond that, you declare a constant but don't tell it what type the constant is, so try
C#
const int MAX_BOOK = 5;
You haven't terminated your Console.WriteLine with a semi-colon. Make this:
C#
Console.WriteLine("You are at your limit!");
Now, some general comments. First of all, you declare book but you don't set it to a value so it will never trigger the WriteLine condition because an int defaults to 0. I assume you mean to assign it to be the length of the array, so you actually need to use that value in there (hint - you need to use books.Length).

Secondly, you have declared a constant that you don't use - this is not a great idea; use the constant in place of the 5 in the if test.

Honestly, this is fairly basic stuff. You have to learn to read the compiler output and figure this stuff out. I saw the problems in your code just by looking at it - I didn't have the advantage of the compiler errors here; you do, so learn to use them. If you're using Visual Studio, the errors will be underlined and they will tell you exactly what's wrong.

Forgive your enemies - it messes with their heads

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


GeneralRe: C# question? Pin
harold aptroot15-Dec-11 6:22
harold aptroot15-Dec-11 6:22 
QuestionWindows 7: Automatic file delete? Pin
Paladin200015-Dec-11 4:52
Paladin200015-Dec-11 4:52 
QuestionThread Abort Exception Pin
anishkannan15-Dec-11 0:27
anishkannan15-Dec-11 0:27 
AnswerRe: Thread Abort Exception Pin
BobJanova15-Dec-11 22:32
BobJanova15-Dec-11 22:32 
GeneralRe: Thread Abort Exception Pin
anishkannan15-Dec-11 22:54
anishkannan15-Dec-11 22:54 
QuestionCreate a licence file. Pin
Jitendra Parida - Jeetu15-Dec-11 0:03
Jitendra Parida - Jeetu15-Dec-11 0:03 
QuestionReplace File Only If Newer (Deployment) Pin
PDaniels3314-Dec-11 23:28
PDaniels3314-Dec-11 23:28 
AnswerRe: Replace File Only If Newer (Deployment) Pin
Not Active15-Dec-11 0:25
mentorNot Active15-Dec-11 0:25 
QuestionHow to find coordinates of each word in pdf file using iTextSharp Pin
NarVish14-Dec-11 23:18
NarVish14-Dec-11 23:18 
QuestionMake a sql query object by C#. Pin
Vincet Shen14-Dec-11 17:05
Vincet Shen14-Dec-11 17:05 
AnswerRe: Make a sql query object by C#. Pin
OriginalGriff14-Dec-11 21:35
mveOriginalGriff14-Dec-11 21:35 
GeneralRe: Make a sql query object by C#. Pin
Vincet Shen15-Dec-11 22:11
Vincet Shen15-Dec-11 22:11 
QuestionEvent Handler for button clicks Pin
Miwin Solutions14-Dec-11 7:43
Miwin Solutions14-Dec-11 7:43 
AnswerRe: Event Handler for button clicks Pin
Luc Pattyn14-Dec-11 8:28
sitebuilderLuc Pattyn14-Dec-11 8:28 
GeneralRe: Event Handler for button clicks Pin
Miwin Solutions14-Dec-11 9:24
Miwin Solutions14-Dec-11 9:24 
GeneralRe: Event Handler for button clicks Pin
Miwin Solutions14-Dec-11 22:46
Miwin Solutions14-Dec-11 22:46 
GeneralRe: Event Handler for button clicks Pin
Luc Pattyn14-Dec-11 23:41
sitebuilderLuc Pattyn14-Dec-11 23:41 

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.