Skip to content

Instantly share code, notes, and snippets.

@mawiseman
Created March 26, 2018 22:56
Show Gist options
  • Save mawiseman/df23594c570bb27c17d9c4569663e72f to your computer and use it in GitHub Desktop.
Save mawiseman/df23594c570bb27c17d9c4569663e72f to your computer and use it in GitHub Desktop.
using Sitecore.Data;
using Sitecore.Data.Items;
public static class ItemExtensions
{
public static T GetValueAs<T>(this Item contextItem, ID settingFieldID)
{
return (T)System.Convert.ChangeType(contextItem.Fields[settingFieldID].Value, typeof(T));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment