تخطَّ إلى المحتوى

Use cast instead of select (ARCH606)

هذا المحتوى غير متوفر بلغتك بعد.

Key dotnet.performance.use-cast-instead-of-select · Severity info · Category performance

A Select lambda that only casts adds an unnecessary delegate invocation; Cast<T>() does it directly.

var strings = objects
.Select(o => (string)o)
.ToList();
var strings = objects
.Cast<string>()
.ToList();

Use Cast<T>() for type conversion.