how to create and trigger a function unity animation events

C#
// Animation Event example
// Small example that can be called on each specified frame.
// The code is executed once per animation loop.using UnityEngine;
using System.Collections;public class Example : MonoBehaviour
{
    public void PrintEvent()
    {
        Debug.Log("PrintEvent");
    }
}

Source

Also in C#: