Reputation: 2577
td.Triggers.Add(New DailyTrigger{DaysInterval = 2})
^^^ this is C#.NET code.
how to do it in VB.NET? I'm particularly confused about curly braces part, because VB.NET doesn't seem to be liking it.
Upvotes: 3
Views: 185
Reputation: 43743
To explain the curly braces, that's just a shortcut for the following:
DailyTrigger dt = new DailyTrigger();
dt.DaysInterval = 2;
td.Triggers.Add(dt);
So, the equivalent in VB would simply be:
Dim dt As DailyTrigger = new DailyTrigger()
dt.DaysInterval = 2
td.Triggers.Add(dt)
Or, to use the similar With
shortcut:
td.Triggers.Add(New DailyTrigger() With { .DaysInterval = 2 })
But that shortcut syntax was not added to VB.NET until a later version (part of LINQ, I believe), so if you aren't using the latest version of .NET, that may not work.
Upvotes: 3
Reputation: 20745
td.Triggers.Add(New DailyTrigger() With { _
Key .DaysInterval = 2 })
Upvotes: 3