0 Members and 1 Guest are viewing this topic.
For example creating generic functions for SymbolTables then more specific for each of the Tables derived from SymbolTable,
Hi,The Yield statement only exists in VB 11 .NET 4.5.Gaston Nunez
Quote from: Jeff H on May 31, 2013, 11:26:54 PMFor example creating generic functions for SymbolTables then more specific for each of the Tables derived from SymbolTable, Funny you should mention that. Since SymbolTableRecord doesn't implement IEnumerable, but its dependents are expected to, we could use this loophole. Code - vb.net: [Select] <ExtensionAttribute()> Public Iterator Function GetObjects(Of T As DBObject)(str As SymbolTableRecord) As IEnumerable(Of T) For Each objectId As ObjectId In CType(str, IEnumerable) Dim target As T = TryCast(objectId.GetObject(OpenMode.ForRead, False, False), T) If target IsNot Nothing Then Yield target End If Next End Function
Certain people abhor passing a non-generic sequence to a functon which will produce run-time errors when fed an argument of the wrong type, like string (IEnumerable of char), when a sequence of ObjectId is expected. Make it an overload of the specific class.