Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# to VB Conversion

Posted on 2010-11-10
3
Medium Priority
?
223 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

618 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