This link offers sample code to infer the schema of an XML file, in VB.NET. One particular line fails in my translation to C#, namely,
Dim schema As XmlSchema = schemaSet.Schemas()(0)
My translation is
XmlSchema schema = schemaSet.Schemas()[0];
I cannot see what is wrong with my translation?
XmlSchemaSet.Schemas() returns an
ICollectionwhich you can’t access by index. If you use use .NET 3.5 you can use Linq to do:Otherwise you have to use a
foreachloop and stop after the first iteration.