Timestamp is just a regular class - so you need to create a new instance before setting properties, e.g.
// Don't actually use this - see below.
test._timeStamp = new Timestamp
{
Seconds = DateTime.Now.Second,
Nanos = DateTime.Now.Second * 100
};
However, there are various things wrong with this:
- That will only give you a Seconds value in the range 0-59
- You're evaluating DateTime.Now twice, so you could get different values
- You're using DateTime.Now which is a *local* time; Timestamp is for global timestamps
Fortunately, there's a factory method to make all of this easy:
test._timeStamp = Timestamp.FromDateTime(DateTime.UtcNow);