Solved

C# to VB Conversion

Posted on 2010-11-10
3
215 Views
Last Modified: 2012-05-10
I have the following code that will solve a problem that I am having.  The issue is that I need to be written in VB rather than C#.

privateT GetParent<T>(DependencyObject obj)
    where T : DependencyObject
{
    if(obj == null)
    {
        returnnull;
    }
    elseif(obj isT)
    {
        return(T)obj;
    }
 
    DependencyObject parent = VisualTreeHelper.GetParent(obj);
    returnGetParent<T>(parent);
}

Open in new window


Any help to convert this code would be greatly appreciated.
0
Comment
Question by:kmcbrearty
3 Comments
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 34102461
Hi there,

You could try the following:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
0
 
LVL 3

Author Comment

by:kmcbrearty
ID: 34102493
I am well aware that conversion programs exist and have already tried them.  Did you bother to even try to use this tool?  The reponse is:

Conversion results
-- line 1 col 1: EOF expected
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34102828
I think it should be:
    Private Function GetParent(Of T As DependencyObject)(ByVal obj As DependencyObject)



        If obj Is Nothing Then

            Return Nothing

        ElseIf TypeOf (obj) Is T Then

            Return DirectCast(obj, T)

        End If



        Dim parent As DependencyObject = VisualTreeHelper.GetParent(obj)

        Return GetParent(Of T)(parent)



    End Function

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now