03.01.2015 Views

Complete set: Intro to C - Bill Buchanan

Complete set: Intro to C - Bill Buchanan

Complete set: Intro to C - Bill Buchanan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Program 7.8:<br />

using System;<br />

namespace ConsoleApplication1<br />

{<br />

class People<br />

{<br />

private string name;<br />

Figure 7.3: Example of object method<br />

}<br />

public string Name<br />

{<br />

get {return name;}<br />

<strong>set</strong> {name=value;}<br />

}<br />

public virtual void ToLowerCase()<br />

{<br />

name=name.ToLower();<br />

}<br />

duction <strong>to</strong> .NET<br />

<strong>Intro</strong><br />

class Profile : People<br />

{ // Inherit from People<br />

public void Display()<br />

{<br />

Console.WriteLine("Name: "+Name);<br />

}<br />

}<br />

public override string ToString()<br />

{<br />

return("Cannot implement this method");<br />

}<br />

class Test<br />

{<br />

static void Main()<br />

{<br />

Profile p1 = new Profile();<br />

Agilent .NET Course: Objects 15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!