Wrox Programmer Forums
|
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2011, 01:53 PM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 2
Thanked 0 Times in 0 Posts
Default Chapter 13 overloaded WriteErrorLog(string msg)

Good evening,

Ive just read the section on p348. You state that if clsErrorLog is already instantiated and the user wants to write another error message to the file then the overloaded WriteErrorLog method is called.

Ive changed the boolean from False to True in the original WriteErrorLog method and then i have selected different radio buttons and clicked the Throw button but each time i single step through i cant get it to execute the overloaded method.

Im basically having issues understanding how the compiler knows that its suppose to call the overloaded method.

if you could clarify that i would appreciate it.

Thanks in advance.
 
Old May 17th, 2011, 09:23 PM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default WriteErrorLog

The reason you can't get the parametized version of WriteErrorLog() to fire is because it's not called anywhere in that code. However, if you look near the bottom of the main form, you'll find:

Code:
finally
{
clsErrorLog myErrLog = newclsErrorLog(err);
myErrLog.PathName = Application.StartupPath;
myErrLog.WriteErrorLog();
txtErrorMsgs.Text = myErrLog.ReadErrorLog();
}
To call the parametized version, change the fifth line to:

myErrLog.WriteErrorLog(err);

Now, because the WriteErrorLog() method has a parameter being passed to it, the compiler knows to call the second version of the method. Single step through it and you will see how it works. The second version allows you more flexibility to pass in to the error log file some other kind of message you might wish to store.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
 
Old May 18th, 2011, 03:56 AM
Authorized User
 
Join Date: Feb 2011
Posts: 21
Thanks: 2
Thanked 0 Times in 0 Posts
Default My bad

Aye ok, i must have misunderstood what you had written as i was under the impression that the overloaded method was being called yet the only call i could find was for the non-overloaded method.

Thanks again





Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 9... Sending email msg argonzal BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 21st, 2011 04:12 AM
overloaded methods ew6014 BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 2 February 19th, 2010 02:33 AM
Error msg: Invalid connection string attribute cJeffreywang ASP.NET 2.0 Basics 3 April 28th, 2008 11:40 AM
How to call C# COM overloaded functions from ASP? khaledriyal C# 0 October 11th, 2005 03:13 AM
C# Overloaded Method argument problem Scott Rider C# 1 January 3rd, 2005 06:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.