Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Sometimes you want to refer to an object in a more general sense. Most people understand user interfaces so here is a basic example: </p> <p>Suppose you have a screen where you want every control to be disabled until some sort of cue, ie. a user fills in some initial input. Your controls may be things like Textboxes, Comboboxes (dropdowns), or Buttons. A way you can refer to all of the above in one fell swoop is to treat them as Controls.</p> <p>You might write code like: </p> <pre><code>foreach(Control c in MyForm.Controls)c.Enabled = false; </code></pre> <p>This is one example but as you start programming more you'll see this is a pretty basic part of your object oriented existence. </p> <p>One place where you can see most object oriented base class libraries employ this technique is with I/O - all input and output libraries available. In the most abstract sense you'll have a Stream but when you look at the class hierarchy you'll see polymorphic variations of the Stream concept: a file stream, a network stream, and so on. Reading and writing stream implementations will be done with "Readers" and "Writers" respectively. Doing some basic programming tasks will get you a really nice feel for how useful this polymorphism is. For example, writing code that reads from a stream and then abstracting it so that it can apply to any implementation of Stream that it is handed. </p> <p>One thing I always try to suggest to people is to study the built in libraries to see how framework designers and programmers employ techniques like this effectively for very practical day to day usage. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload