Using LINQ to retrieve Fonts

Well a long time has past, and I was not able to post anything good so I thought to not let my blog die I post something pretty simple but also powerful LINQ is a great future which you can find in .NET 3.5 and above it makes programming a lot easier since Microsoft has worked pretty hard.
So in this simple example I show you how you can retrieve all the font names using LINQ
Okay this is the function which is mostly self explained

    Private Function GetFontNames() As List(Of String)

        Dim Query = From fntName In FontFamily.Families
            Select fntName.Name

        Return Query.ToList

    End Function

you can call it from your application like this

ListBox1.DataSource = GetFontNames()

 In this example i used a ListBox and bound it’s datasource to the List which the GetFontNames()
Function returns.

This is how all will look like, as I’m not gonna write down what your able to do with link i suggest you to read more about

LINQ on the MSDN page for LINQ: .

I wish you all got time reading, hope I’ll get some free time so I can post anything cool in here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s