As a “safe check” code operation in Sitecore, you frequently check for expected field type before working with a field. While there is an easy way to do it via “Type” property of a field returning string, it may not look really nice and considered hard-coding:

if (Sitecore.Context.Item.Fields["featured"].Type == "Droplink")

Plus backwards compatibility of such code is questionable.

 

I suggest you use the Sitecore.Data.Fields.FieldTypeManager class that has “GetField” method where you can pass the instance of your field and use “IS” keyword to check if it is safe to cast:

if (FieldTypeManager.GetField(Sitecore.Context.Item.Fields["title"]) is TextField)
if (FieldTypeManager.GetField(Sitecore.Context.Item.Fields["text"]) is HtmlField)
if (FieldTypeManager.GetField(Sitecore.Context.Item.Fields["featured"]) is LookupField)
if (FieldTypeManager.GetField(Sitecore.Context.Item.Fields["metakeywords"]) is MultilistField)

Just make sure to replace the field name strings with a reference to a GUID class and you will be all set!