Home Rules Refactorings Generators

BH0017: Prefer Target-Typed new

This is a way to reduce the code length even a little.

Code with violation

public class TestClass {
    public void TestMethod() {
        var o = new object();
    }
}

Fixed Code

public class TestClass {
    public void TestMethod() {
        object o = new();
    }
}

Copyright © 2025 Bluehill