public LocalizedDisplayNameAttribute(string displayNameKey)
: base(displayNameKey)
{
}
if i put :base after the function in the class what does that mean?
public LocalizedDisplayNameAttribute(string displayNameKey)
: base(displayNameKey)
{
}
if i put :base after the function in the class what does that mean?
base indicates that you're calling the base class' constructor from this class' constructor.
It is only valid for constructors, not regular methods. In your case, when a LocalizedDisplayNameAttribute is created, it passes the displayNameKey parameter to its base class' constructor.
It means that you will invoke the according constructor of the base class of your class.
Consider this:
public class A {
public A() {
Console.WriteLine("You called the first constructor");
}
public A(int x) {
Console.WriteLine("You called the second constructor with " + x);
}
}
public class B : A {
public B() : base() { } // Calls the A() constructor
}
public class C : A {
public C() : base(10) { } // Calls the A(int x) constructor
}
public class D : A {
public D() { } // No explicit base call; Will call the A() constructor
}
...
new B(); // Will print "You called the first constructor"
new C(); // Will print "You called the second constructor with 10"
new D(); // Will print "You called the first constructor"
If this still doesn't make any sense, you should probably read a bit more about constructors in object oriented languages, for example here.
What you have there is a Constructor and not a function or method (a constructor is a special method that is called automatically when your class is instantiated). Adding :base(parameter) after the constructor allows you to call the constructor of the base class (the class your class inherited from) with the parameter passed into your class constructor.
A good tutorial on constructors can be found at http://www.yoda.arachsys.com/csharp/constructors.html which should help clear this up.