oo-70-245-1

oo-70-245-1 Commit Details


Date:2015-09-21 18:50:27 (9 years 3 months ago)
Author:Natalie Adams
Branch:master
Commit:75071bf8dfd9cabee21234ceb68ea5a2b5b7beef
Parents: c8d2f5a49fe0883ab8d7854159a758449a2f1863
Message:adding example 8

Changes:

File differences

Day 2 Class Examples/Example8/Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace classex3
{
public class BaseClass
{
public virtual void DoWork()
{
Console.WriteLine("BaseWork");
}
public int WorkField;
public int getWorkProperty() { return 0; }
public void setWorkProperty(int value) { this.WorkField = value; }
public int WorkProperty
{
get { return 0; }
set { this.WorkField = value; }
}
}
public class DerivedClass : BaseClass
{
public override void DoWork() { Console.WriteLine("DerivedWork"); }
public new int WorkField;
public new int WorkProperty
{
get { return 0; }
}
}
class Program
{
static void Main(string[] args)
{
DerivedClass B = new DerivedClass();
BaseClass A = (BaseClass)B;
B.DoWork();
A.DoWork();
//A.WorkProperty = 20;
//int x = A.WorkProperty;
}
}
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.05425s using 14 queries.