webForumDet fria alternativet

PrivateFontCollection

.NETur .NET

1 svar · 221 visningar · startad av DavidB

Medlem sedan jan. 20001 372 inlägg
Frågan#1

varför fungerar den överska koden (VB) men inte den nedersta (C#)?

Dim privateFontCollection As New PrivateFontCollection()
privateFontCollection.AddFontFile(Server.MapPath("BAMBOO.TTF"))
Dim thisFont As FontFamily = privateFontCollection.Families(0)
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(Server.MapPath("BAMBOO.TTF"));[red]
FontFamily thisFont = pfc.Families(0);[/red]

får följande fel om jag kör den nedersta:
'System.Drawing.Text.FontCollection.Families' denotes a 'property' where a 'method' was expected

Medlem sedan apr. 20012 266 inlägg
#2

Ta bort (0) från families och kör med [0] eftersom den retunerar en collection.

133 ms totalt · 3 externa anrop · v20260731065814-full.25f56b17
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
131 ms — hämta tråd, inlägg och bilagor (db)