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

x
?
Solved

Convert from C# to VB.net

Posted on 2013-01-18
4
Medium Priority
?
390 Views
Last Modified: 2013-01-18
Hello.  I ran this code through a converter but it failed :(

I don't understand the purpose of the square brackets in C#

Could someone convert it for me please?

[Table]
public class ToDoItem : INotifyPropertyChanged, INotifyPropertyChanging
{
// Define ID: private field, public property and database column.
private int _toDoItemId;

[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public int ToDoItemId
{
    get
    {
        return _toDoItemId;
    }
    set
    {
        if (_toDoItemId != value)
        {
            NotifyPropertyChanging("ToDoItemId");
            _toDoItemId = value;
            NotifyPropertyChanged("ToDoItemId");
        }
    }
}

// Define item name: private field, public property and database column.
private string _itemName;

[Column]
public string ItemName
{
    get
    {
        return _itemName;
    }
    set
    {
        if (_itemName != value)
        {
            NotifyPropertyChanging("ItemName");
            _itemName = value;
            NotifyPropertyChanged("ItemName");
        }
    }
}

// Define completion value: private field, public property and database column.
private bool _isComplete;

[Column]
public bool IsComplete
{
    get
    {
        return _isComplete;
    }
    set
    {
        if (_isComplete != value)
        {
            NotifyPropertyChanging("IsComplete");
            _isComplete = value;
            NotifyPropertyChanged("IsComplete");
        }
    }
}
// Version column aids update performance.
[Column(IsVersion = true)]
private Binary _version;

#region INotifyPropertyChanged Members

public event PropertyChangedEventHandler PropertyChanged;

// Used to notify the page that a data context property changed
private void NotifyPropertyChanged(string propertyName)
{
    if (PropertyChanged != null)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

#endregion

#region INotifyPropertyChanging Members

public event PropertyChangingEventHandler PropertyChanging;

// Used to notify the data context that a data context property is about to change
private void NotifyPropertyChanging(string propertyName)
{
    if (PropertyChanging != null)
    {
        PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
    }
}

#endregion
}

Open in new window

0
Comment
Question by:Dodsworth
[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
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38792963
Square brackets (as used above) denote attributes. In VB.NET, you use angle brackets ( < > ) for attributes.

Does this work? If not, what line(s) are in error?

<Table> _
Public Class ToDoItem
    Implements INotifyPropertyChanged
    Implements INotifyPropertyChanging
    ' Define ID: private field, public property and database column.
    Private _toDoItemId As Integer

    <Column(IsPrimaryKey := True, IsDbGenerated := True, DbType := "INT NOT NULL Identity", CanBeNull := False, AutoSync := AutoSync.OnInsert)> _
    Public Property ToDoItemId() As Integer
        Get
            Return _toDoItemId
        End Get
        Set
            If _toDoItemId <> value Then
                NotifyPropertyChanging("ToDoItemId")
                _toDoItemId = value
                NotifyPropertyChanged("ToDoItemId")
            End If
        End Set
    End Property

    ' Define item name: private field, public property and database column.
    Private _itemName As String

    <Column> _
    Public Property ItemName() As String
        Get
            Return _itemName
        End Get
        Set
            If _itemName <> value Then
                NotifyPropertyChanging("ItemName")
                _itemName = value
                NotifyPropertyChanged("ItemName")
            End If
        End Set
    End Property

    ' Define completion value: private field, public property and database column.
    Private _isComplete As Boolean

    <Column> _
    Public Property IsComplete() As Boolean
        Get
            Return _isComplete
        End Get
        Set
            If _isComplete <> value Then
                NotifyPropertyChanging("IsComplete")
                _isComplete = value
                NotifyPropertyChanged("IsComplete")
            End If
        End Set
    End Property
    ' Version column aids update performance.
    <Column(IsVersion := True)> _
    Private _version As Binary

    #Region "INotifyPropertyChanged Members"

    Public Event PropertyChanged As PropertyChangedEventHandler

    ' Used to notify the page that a data context property changed
    Private Sub NotifyPropertyChanged(propertyName As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
    End Sub

    #End Region

    #Region "INotifyPropertyChanging Members"

    Public Event PropertyChanging As PropertyChangingEventHandler

    ' Used to notify the data context that a data context property is about to change
    Private Sub NotifyPropertyChanging(propertyName As String)
        RaiseEvent PropertyChanging(Me, New PropertyChangingEventArgs(propertyName))
    End Sub

    #End Region
End Class

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================

Open in new window

0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38793003
that's solved the square bracket problem


errors on

Implements INotifyPropertyChanged
Implements INotifyPropertyChanging

Error      1      Class 'ToDoItem' must implement 'Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs)' for interface 'System.ComponentModel.INotifyPropertyChanged'.      C:\Users\maf\documents\visual studio 2010\Projects\BTDT\BTDT\MainPage.xaml.vb      55      20      BTDT
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 38793055
Change line 61 in my last snippet to:

Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

Open in new window


...and line 72 to:

Public Event PropertyChanging As PropertyChangingEventHandler Implements INotifyPropertyChanging.PropertyChanging

Open in new window

0
 
LVL 1

Author Closing Comment

by:Dodsworth
ID: 38793376
thanks
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 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