Wrox Programmer Forums
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 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 December 1st, 2016, 08:45 PM
Registered User
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
 ((Button)sender).Content = "Clicked!";
makes use of polymorphism but I am not understanding how this thing uses polymorphism?

My Second understanding problem with
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..
Old January 29th, 2017, 03:46 AM
Friend of Wrox
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts

in order to understand how this block of 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
((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
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.

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 03: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 07:11 AM

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