?
Solved

C# to VB Conversion

Posted on 2010-11-10
3
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

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:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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