views:

56

answers:

1

When i am creating SPFields the constructor states that you must pass in a collection of fields.

Can anyone enlighten me on why?

Thanks in advanced Truez

+1  A: 

The constructor wants some contextual information about which collection of fields it will be added to. You shouldn't create new fields this way, though. Instead, use SPFieldCollection.Add() - which will construct the object and add it to the appropriate collection.

Bradley Smith
Thanks for the reply, I am doing it this way so I construct a loop to check that the fields don't already exist otherwise i would have to put a check around every field that I add to the collection otherwise there is the possibility that duplications will occur so i believe. Have you got any other ways of doing this i am fairly new to sharepoint
Truezplaya
You can use `SPFieldCollection.ContainsField()` to do your duplicate check.
Bradley Smith