나는 WPF를 배우고 내가 상당히 제약 선언 방법을 이해하지 못하는 코드 조각있다 :이 공유 방법 이해코드 구문 explaination 도움
public static T FindAncestor<T>(DependencyObject dependencyObject)
where T : class // Need help to interpret this method declaration
및 T 클래스 수있다는 하지만 정적 T FindAncestor는 무엇입니까? 그것을 전체적으로 해석하는 데 어려움이 있습니다. 감사!
코드 :
public static class VisualTreeHelperExtensions
{
public static T FindAncestor<T>(DependencyObject dependencyObject)
where T : class // Need help to interpret this method
{
DependencyObject target = dependencyObject;
do
{
target = VisualTreeHelper.GetParent(target);
}
while (target != null && !(target is T));
return target as T;
}
}
종합적인 설명 주셔서 감사합니다. – k80sg