Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 30th, 2006, 08:19 AM
Registered User
 
Join Date: Aug 2006
Location: Mehsana, Gujarat, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hpatel_it Send a message via Yahoo to hpatel_it
Default Some confusion in these code

Hi,

I have read out one sample online article about Interface & Abstract Class. In that article all are mentioned in good way and easily understandable but I have a problem in understanding following code.

Article Link :
http://www.codeproject.com/csharp/A...SInterfaces.asp

In Following code, Lines which are marked by RED color its not understandablel by me.

In short , in first function why we need to use Casting and while in second function why we dont need to use casting.

Can you please help me out for this ?

Code :

private void InterfaceExample_Click(object sender,
System.EventArgs e)
{
try
{

IEmployee emp;

Emp_fulltime2 emp1 = new Emp_fulltime2();
//has to be casted because of the interface!
emp = (IEmployee) emp1;
emp.ID = "2234";
emp.FirstName= "Rahman" ;
emp.LastName = "Mahmoodi" ;
//call add method od the object
MessageBox.Show(emp.Add().ToString());

//call the CalculateWage method
MessageBox.Show(emp.CalculateWage().ToString());


}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

}

private void cmdAbstractExample_Click(object sender,
System.EventArgs e)
{

Employee emp;
//no casting is requird!
emp = new Emp_Fulltime();

emp.ID = "2244";
emp.FirstName= "Maria" ;
emp.LastName = "Robinlius" ;
MessageBox.Show(emp.Add().ToString());

//call the CalculateWage method
MessageBox.Show(emp.CalculateWage().ToString());

}

Thanks,
Hiren Patel
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Errata confusion morganstein BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 0 October 10th, 2008 05:11 PM
Confusion with PLATFORM, Help me Please! dpkbahuguna .NET Framework 2.0 10 September 28th, 2007 08:41 AM
foreach confusion stokerfed C# 2 June 13th, 2007 02:30 PM
.net Confusion reyboy General .NET 1 December 29th, 2004 08:35 AM



All times are GMT -4. The time now is 11:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.