[c#] What are your favorite extension methods for C#? (codeplex.com/extensionoverflow)

There is somethimes need to have instance of class no matter if valid but not null

public static T Safe<T>(this T obj) where T : new()
{
    if (obj == null)
    {
        obj = new T();
    }

    return obj;
}

usage will be like:

MyClass myClass = Provider.GetSomeResult();
string temp = myClass.Safe().SomeValue;

instead of:

MyClass myClass = Provider.GetSomeResult();
string temp = "some default value";
if (myClass != null)
{
        temp = myClass.SomeValue;
}

sorry if it is a duplicity, but I dont find it.

Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to open-source

Open Source Javascript PDF viewer Open Source Alternatives to Reflector? Open-Source Examples of well-designed Android Applications? What does "commercial use" exactly mean? What is the best open source help ticket system? Are there any Open Source alternatives to Crystal Reports? Anybody knows any knowledge base open source? What are your favorite extension methods for C#? (codeplex.com/extensionoverflow) What is the best open XML parser for C++? What are some great online database modeling tools?

Examples related to extension-methods

The operation cannot be completed because the DbContext has been disposed error Extension methods must be defined in a non-generic static class Java equivalent to C# extension methods Razor HtmlHelper Extensions (or other namespaces for views) Not Found Mocking Extension Methods with Moq AddRange to a Collection Distinct() with lambda? Convert string[] to int[] in one line of code using LINQ How do I extend a class with c# extension methods? Static extension methods