Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Created November 17, 2020 18:33
Show Gist options
  • Save zHaytam/2df773102a43e2864ba2f1370a4bfe11 to your computer and use it in GitHub Desktop.
Save zHaytam/2df773102a43e2864ba2f1370a4bfe11 to your computer and use it in GitHub Desktop.
public string GetCategoryId(object instance)
=> (instance as ListProductsRequest).CategoryId;
// Or as a lambda expression (which will help us more)
Func<object, string> getCategoryId = (instance) => (instance as ListProductsRequest).CategoryId;
// We can also generalize it
Func<object, object> getCategoryId = (instance) => (object)((instance as ListProductsRequest).CategoryId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment