0

I 'm not familiar with C#.NET at all. I need to convert this to VB. Can anyone please give me a hand?

public IEnumerable<CodecInfo> AudioCodecs
        {
            get { return softPhone.Codecs.Where(c => c.CodecType == CodecMediaType.Audio); }
        }

Thanks

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
Suneesh.sh
  • 23
  • 5

3 Answers3

5
Public ReadOnly Property AudioCodecs As IEnumerable(Of CodecInfo)
    Get
        Return From c In softPhone.Codecs
               Where c.CodecType = CodecMediaType.Audio
    End Get
End Property

Query syntax is much more readable than method syntax in VB.NET

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
  • 2
    *Query syntax is much more readable in VB.NET* - That's true, it's even more powerfull than in C# – sloth Aug 16 '12 at 13:17
  • How is that more readable than the same query in C#? `from c in softPhone.Codecs where c.CodecType == CodecMediaType.Audio`, right? Looks pretty easy to read to me (except for being in a comment). – Tim Aug 16 '12 at 14:50
  • I don't see how it's more readable than the C# version. LINQ syntax is fairly consistent across both languages. The only key difference here is the C# version is compressed for space to put the property accessor and code on a single line, where the VB.Net forces you to be multiline, but that's not the query syntax itself. – Maurice Reeves Aug 16 '12 at 14:55
  • Maybe it's not the best example, so have a look at this: http://stackoverflow.com/a/9039282/284240 – Tim Schmelter Aug 16 '12 at 15:08
  • You have both misunderstood my note so i've edited my answer to clarify it (hopefully). – Tim Schmelter Aug 16 '12 at 17:51
3
Public ReadOnly Property AudioCodecs() As IEnumerable(Of CodecInfo)
    Get
        Return softPhone.Codecs.Where(Function(c) c.CodecType = CodecMediaType.Audio)
    End Get
End Property

In future you can use a C#-VB.NET converter:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

Curtis
  • 101,612
  • 66
  • 270
  • 352
0
Public ReadOnly Property AudioCodecs() As IEnumerable(Of CodecInfo)
    Get
        Return softPhone.Codecs.Where(Function(c) c.CodecType = CodecMediaType.Audio)
    End Get
End Property
Flash
  • 15,945
  • 13
  • 70
  • 98