ObjectContent is a class in the System.Net.Http.Formatting namespace of the Microsoft ASP.NET Web API 2.2 package library. It represents an HTTP content based on an object and a specific media type formatter.
Example 1: Creating an ObjectContent from a string using StringContent formatter
var myObject = "Hello World!";
var content = new ObjectContent(myObject, new System.Net.Http.Formatting.StringContent());
In this example, the ObjectContent is created from a string object "Hello World!" using the StringContent formatter which converts the string into HTTP content with media type "text/plain".
Example 2: Creating an ObjectContent from a custom object using JsonMediaTypeFormatter
var myObject = new { Name = "John", Age = 30 };
var content = new ObjectContent