Você está na página 1de 3

Static member is a member of the class, not a member of an instance of the class

Static methods must use static members and other static methods

public Account (string inName) : this (inName, "Unknown adress", 0) { }

Able to create reference variables which refer to objects in terms of interfaces they
implement,
rather than the particular type that they are.

If you apply the "abstraction" technique properly you should end up with a system
creation process which goes along the lines of:
gather as much metadata as you can about the problem; what is important to the
customer, what values need to be represented and manipulated and the range of
those values
identify classes that you will have to create to represent the components in the
problem
identify the actions (methods) and the values (properties) that the components
must provide
put these into interfaces for each of the components
decide how these values and actions are to be tested
implement the components and test them as you go

virtual methods, protected members, override methods

base.functionCall

make class sealed - cannot be extended

public Child (type param) : base (type param) {}

abstract methods - to be implemented in child, making the class abstract as well


must be MARKED ABSTRACT

abstract methods may contain fully implemented methods, interface only holds
declarations

Interface: lets you identify a set of behaviours (i.e. methods) which a component
can be made to implement. Any component which implements the interface can be
thought of in terms of a reference of that interface type. A concrete example of this
would be something like IPrintHardCopy. Lots of items in my bank system will need
to do this and so we could put the behaviour details into the interface for them to
implement in their own way. Then our printer can just regard each of the instances
that implement this interface purely in this way. Interfaces let me describe a set of
behaviours which a component can implement. Once a component can implement
an interface it can be regarded purely in terms of a component with this ability.
Objects can implement more than one interface, allowing them to present different
faces to the systems that use them.
Abstract: lets you create a parent class which holds template information for all the
classes which extend it. If you want to create a related set of items, for example all
the different kinds of bank account you might need to deal with, including credit
card, deposit account, current account etc. then the best way to do this is to set up
a parent class which contains abstract and non-abstract methods. The child classes
can make use of the methods from the parent and override the ones that need to be
provided differently for that particular class.

public override string ToString()

public override string ToString()


{ return base.ToString() + " Parent : " + parentName; }

public override bool Equals(object obj)


{ Point p = (Point) obj;
}

string s1="Rob"; s1=s1.Substring(1,2);


The first parameter is the starting position and the second is the number of
characters to be copied.

Useful string methods: ToUpper, ToLower, Trim, TrimStart, TrimEnd


For proper string editing C# provides a class called StringBuilder. It is found in the
System.Text namespace.

public class StaffMember


private int ageValue;
public int Age
{ set
{ if ( (value > 0) && (value < 120) )
{ this.ageValue = value; }
} get { return this.ageValue; }
}}

public int AgeInMonths


{ get { return this.ageValue*12; } }

interface IStaff
{ int Age
{ get; set; } }

Você também pode gostar