How to create TimerTask without creating functions?

I just need to create a TimerTask in one place without creating any variables or functions

For example this

Timer timer = new Timer(1000)
{
    void Task()
    {
        // To Do
    }
}