Use generic pattern match

>7.0 c#
This commit is contained in:
Kurt
2019-05-13 15:53:27 -07:00
parent 2b39d75141
commit 04cd0da2ac
2 changed files with 2 additions and 4 deletions

View File

@@ -101,8 +101,7 @@ private static IEnumerable<object> GetTranslatableControls(Control f)
{
foreach (Control child in control.Controls)
{
var childOfT = child as T;
if (childOfT != null)
if (child is T childOfT)
yield return childOfT;
if (!child.HasChildren) continue;

View File

@@ -28,8 +28,7 @@ internal static void CenterToForm(this Control child, Control parent)
{
while (true)
{
var t = aParent as T;
if (t != null)
if (aParent is T t)
return t;
if (aParent.Parent != null)