int myInt = 42; TypeWrapper myWrapper = new TypeWrapper(myInt); string myString = myWrapper.As(); // "42"
TypeWrapper myWrapper = new TypeWrapper(null); if (myWrapper.IsNull()) { // Do something if null }
public class MyClass { public int MyValue { get; set; } } MyClass myClass = new MyClass() { MyValue = 42 }; TypeWrapper myWrapper = new TypeWrapper(myClass); int myValue = myWrapper.GetPropertyIn this example, we create a TypeWrapper object around a custom class and then access one of its properties using the GetProperty() method. Overall, TypeWrapper is a useful library for simplifying common operations on objects of different types in C#. The package library for TypeWrapper is likely to be found on nuget.org.("MyValue"); // 42