Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyrest authored Mar 5, 2022
1 parent f4f29e9 commit 17e87c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ if (FastNew.TryCreateInstance<T, string>("arg0", out T result));

### Notes

> **With .NET Framework**, `Activator.CreateInstance<T>()` invokes the parameterless constructor of `ValueType` if the constraint is `where T : new()` but appears to **ignore the parameterless constructor if the constraint is `where T : struct`**.
> **With .NET Framework**, `Activator.CreateInstance<T>()` invokes the parameterless constructor of **ValueType** if
> the constraint is `where T : new()` but appears to **ignore the parameterless constructor if the constraint is `where T : struct`**.
> **But `FastNew.CreateInstance<T>()` will always invoke the parameterless constructor if it's available.**
> If you don't want to invoke the parameterless constructor of `ValueType`.
>
> If you don't want to invoke the parameterless constructor of **ValueType**.
> Consider to use `FastNew.NewOrDefault<T>()` which **will never invoke the parameterless constructor of `ValueType`**
## Benchmark
Expand Down

0 comments on commit 17e87c3

Please sign in to comment.