Solved

C# to VB Conversion

Posted on 2010-11-10
3
216 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

778 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