Skip to content

Instantly share code, notes, and snippets.

@rofr
Created October 31, 2012 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofr/3987204 to your computer and use it in GitHub Desktop.
Save rofr/3987204 to your computer and use it in GitHub Desktop.
An example of verbatim identifiers in C#
protected T LoadFromConfigOrDefault<T>(Func<T> @default = null)
{
@default = @default ?? (() => (T)Activator.CreateInstance(typeof(T)));
string configKey = ConfigKeyFromType(typeof(T));
var configTypeName = ConfigurationManager.AppSettings[configKey];
if (!String.IsNullOrEmpty(configTypeName))
{
return InstanceFromTypeName<T>(configTypeName);
}
else
{
return @default.Invoke();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment