Solved

C# to VB Conversion

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

12 Experts available now in Live!

Get 1:1 Help Now