Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 6 > BOOK: Beginning C# 6.0 Programming with Visual Studio 2015
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning C# 6.0 Programming with Visual Studio 2015
This is the forum to discuss the Wrox book Beginning C# 6.0 Programming with Visual Studio 2015 by Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid; ISBN: 978-1-119-09668-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 6.0 Programming with Visual Studio 2015 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 1st, 2016, 08:45 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Chapter 08 Try it out Ch08Ex01

Hello Everyone,
I am very very new in programming even I don't have any basic of any programming language. I started learning C# from this book and found this book very resourceful and discussed in deep which helps very much. I have an understanding problem on chapter 08 try it out 01.

As per author
Code:
 ((Button)sender).Content = "Clicked!";
makes use of polymorphism but I am not understanding how this thing uses polymorphism?

My Second understanding problem with
Code:
((Grid)((Button)sender).Parent).Children.Add(newButton);
I didn't understand this code at all.

Can anyone help me to understand these?

Thanks in advance.

Last edited by maninblack; December 1st, 2016 at 09:27 PM.
Reply With Quote
  #2 (permalink)  
Old January 29th, 2017, 03:46 AM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

in order to understand how this block of code:
Code:
((Button)sender).Content = "Clicked!";
is using polymorphism, you must understand what it mean. polymorphism means in general terms "many forms". meaning its values can be applied to many type.

A popular example is a car

1) a ford can be car
2) a Chevy can be a car
3) and so on....

the point is that the commonality between the examples is a the noun "car"

lets assume that we have 2 distinct types of cars 1 ford and 1 Chevy but they have similar behaviors (in this example) drive and park. well if we extract those behaviors (drive and park) to a what is known as base class or interface the we can derive "many" types of cars that have the same behavior of drive and park such Toyota and Honda without duplicating code or each.

the block of code
Code:
((Button)sender).Content = "Clicked!";
does not offer much in identifying "polymorphism" per say without the developer knowing that the "sender" object is of a "Button" "type". the block
Code:
(Button)
casts (turns it in) the "sender" into/"masks" so that the sender appears to be a "Button" object and then references its "content" property. this is a core principle of OOP. I would suggest reading up on it.
Reply With Quote
Reply


Thread Tools
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
Chapter 08: Creating Smarter User Controls huttog BOOK: Beginning ASP.NET 4 : in C# and VB 5 June 29th, 2012 04:16 AM
Chapter 8 Ch08Ex01 dampyr BOOK: Beginning Visual C# 2010 3 November 10th, 2011 06:09 AM
Beginning Visual C# Exercises - Chapter 08 seblake C# 2 July 26th, 2004 08:11 AM



All times are GMT -4. The time now is 11:57 AM.


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