Hello Larry,
Thanks for quick reply. I am trying to conver a bif C# file to its
equivalent VB.NET file.
I am a beginer in .net stuff. To give a you little back ground of what
I am doing here is trying to build a remote Admin page (similar to
ASP.NET configuration tool " Web Site Administration Tool " . So I was
searching the web and finally found one site
"http://peterkellner.net/archives/2006/01/09/24/" and the code is in C#
and it works pretty cool. Now, I am trying to convert that code in to
VB.NET.
Yes I am using convertors to convert the C# code to vb.net.
This is the file I am trying to convert from C# to VB.NET
************************************************** **C#
code*******************************************
/*
Copyright © 2005, Peter Kellner
All rights reserved.
http://peterkellner.net
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Neither Peter Kellner, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Collections.ObjectModel;
namespace MembershipUtilities
{
/// <summary>
/// Class Used to Select, Update, Insert and Delete
/// From the Microsoft ASP.NET Membership API
/// </summary>
///
[DataObject(true)] // This attribute allows the ObjectDataSource
wizard to see this class
public class MembershipUserODS
{
/// <summary>
/// This insert method is the default insert method. It is
typically associated with
/// a detailview control for inserting new members.
/// </summary>
/// <param name="userName">MembershipUser.UserName</param>
/// <param name="password">MembershipUser.password</param>
/// <param name="isApproved">MembershipUser.IsApproved</param>
/// <param name="comment">MembershipUser.comment</param>
/// <param
name="lastLockoutDate">MembershipUser.lastLockoutD ate</param>
/// <param
name="creationDate">MembershipUser.creationDate</param>
/// <param name="email">MembershipUser.email</param>
/// <param
name="lastActivityDate">MembershipUser.lastActivit yDate</param>
/// <param
name="providerName">MembershipUser.providerName</param>
/// <param
name="isLockedOut">MembershipUser.isLockedOut</param>
/// <param
name="lastLoginDate">MembershipUser.lastLoginDate</param>
/// <param name="isOnline">MembershipUser.isOnline</param>
/// <param
name="passwordQuestion">MembershipUser.passwordQue stion</param>
/// <param
name="lastPasswordChangedDate">MembershipUser.last PasswordChangedDate</param>
///
[DataObjectMethod(DataObjectMethodType.Insert, true)]
static public void Insert(string userName, bool isApproved,
string comment, DateTime lastLockoutDate, DateTime
creationDate,
string email, DateTime lastActivityDate, string
providerName, bool isLockedOut,
DateTime lastLoginDate, bool isOnline, string
passwordQuestion,
DateTime lastPasswordChangedDate, string password, string
passwordAnswer)
{
// The incoming parameters, password and passwordAnswer are
not properties of the
// MembershipUser class. Membership has special member
functions to deal with these
// two special properties for security reasons. For this
reason, they do not appear
// in a datacontrol that is created with this user object.
//
// the only reason you may want to have defaults is so you
can build insert into your
// datacontrol. A better approach would be to either
follow the example shown in the
// Membership.asp page where the parameters are set
directly to the userobject, or not
// include "new" at all in your control and use the other
controls in the Membership API
// for creating new members. (CreateUserWizard, etc)
//
// It is recommended that you only enable the following
lines if you are sure of what you are doing
//if (password == null)
//{
// password = "pass0word";
//}
//if (passwordAnswer == null)
//{
// passwordAnswer = "Password Answer";
//}
MembershipCreateStatus status;
Membership.CreateUser(userName, password, email,
passwordQuestion, passwordAnswer, isApproved, out status);
if (status != MembershipCreateStatus.Success)
{
throw new ApplicationException(status.ToString());
}
MembershipUser mu = Membership.GetUser(userName);
mu.Comment = comment;
Membership.UpdateUser(mu);
}
/// <summary>
/// Takes as input the original username and the current
username
/// </summary>
/// <param name="providerUserKey"></param>
/// <param name="Original_providerUserKey"></param>
///
[DataObjectMethod(DataObjectMethodType.Delete, true)]
static public void Delete(string UserName)
{
Membership.DeleteUser(UserName, true);
}
/// <summary>
/// This update method is the default update as shown by the
class attribute.
///
/// </summary>
/// <param name="original_UserName">MembershipUser.UserName
originally retrieved</param>
/// <param name="email">MembershipUser.email</param>
/// <param name="isApproved">MembershipUser.isApproved</param>
/// <param name="comment">MembershipUser.comment</param>
/// <param name="password">MembershipUser.password</param>
/// <param
name="passwordAnswer">MembershipUser.passwordAnswe r</param>
/// <param
name="lastActivityDate">MembershipUser.lastActivit yDate</param>
/// <param
name="lastLoginDate">MembershipUser.lastLoginDate</param>
///
[DataObjectMethod(DataObjectMethodType.Update, true)]
static public void Update(string UserName, string email,
bool isApproved, string comment, DateTime
lastActivityDate, DateTime lastLoginDate)
{
bool dirtyFlag = false;
MembershipUser mu = Membership.GetUser(UserName);
if (mu.Comment == null || mu.Comment.CompareTo(comment) !=
0)
{
dirtyFlag = true;
mu.Comment = comment;
}
if (mu.Email == null || mu.Email.CompareTo(email) != 0)
{
dirtyFlag = true;
mu.Email = email;
}
if (mu.IsApproved != isApproved)
{
dirtyFlag = true;
mu.IsApproved = isApproved;
}
if (dirtyFlag == true)
{
Membership.UpdateUser(mu);
}
}
/// <summary>
/// This is just used to set the IsApproved status.
/// username is always passed in for searching purposes.
/// </summary>
/// <param name="original_username">Current UserName to Update
(primary key)</param>
/// <param name="isApproved">MembershipUser.isApproved</param>
///
[DataObjectMethod(DataObjectMethodType.Update, false)]
static public void Update(string Username, bool isApproved)
{
bool dirtyFlag = false;
MembershipUser mu = Membership.GetUser(Username);
if (mu.IsApproved != isApproved)
{
dirtyFlag = true;
mu.IsApproved = isApproved;
}
if (dirtyFlag == true)
{
Membership.UpdateUser(mu);
}
}
/// <summary>
/// Make a list of MembershipUserWrapper objects
/// </summary>
/// <returns>A List of type MembershipUserWrapper</returns>
///
[DataObjectMethod(DataObjectMethodType.Select, false)]
static public List<MembershipUserWrapper> GetMembers()
{
return GetMembers(true, true, null, null);
}
/// <summary>
/// Make a list of MembershipUserWrapper objects by current
sort
/// </summary>
/// <param name="sortData">Whicfh Column to perform the sort
on</param>
/// <returns>A List of type MembershipUserWrapper</returns>
///
[DataObjectMethod(DataObjectMethodType.Select, true)]
static public List<MembershipUserWrapper> GetMembers(string
sortData)
{
// All Users, All approvalStatus
return GetMembers(true, true, null, sortData);
}
/// <summary>
/// returns all approved users by specified sort
/// </summary>
/// <param name="approvalStatus">if true, return approved
users</param>
/// <param name="sortData">description of sort</param>
/// <returns>A List of type MembershipUserWrapper</returns>
///
[DataObjectMethod(DataObjectMethodType.Select, false)]
static public List<MembershipUserWrapper> GetMembers(bool
approvalStatus, string sortData)
{
if (approvalStatus == true)
{
return GetMembers(true, false, null, sortData);
}
else
{
return GetMembers(false, true, null, sortData);
}
}
/// <summary>
/// Return a collection of MembershipUserWrapper's based on
criteria passed in as parameters
/// </summary>
/// <param name="returnAllApprovedUsers">returns all users with
approval set to true</param>
/// <param name="returnAllNotApproviedUsers">return all users
with approval set to false</param>
/// <param name="usernameToFind">return based on username
(overrides approval above)</param>
/// <param name="sortData">sort parameter</param>
/// <returns>Returns a Collection of Users (as recommended by
FxCop)</returns>
///
[DataObjectMethod(DataObjectMethodType.Select, false)]
static public List<MembershipUserWrapper> GetMembers(bool
returnAllApprovedUsers, bool returnAllNotApprovedUsers,
string usernameToFind, string sortData)
{
List<MembershipUserWrapper> memberList = new
List<MembershipUserWrapper>();
// See if we are looking for just one user
if (usernameToFind != null)
{
MembershipUser mu = Membership.GetUser(usernameToFind);
if (mu != null)
{
MembershipUserWrapper md = new
MembershipUserWrapper(mu);
memberList.Add(md);
}
}
else
{
MembershipUserCollection muc =
Membership.GetAllUsers();
foreach (MembershipUser mu in muc)
{
if ((returnAllApprovedUsers == true &&
mu.IsApproved == true) ||
(returnAllNotApprovedUsers == true &&
mu.IsApproved == false))
{
MembershipUserWrapper md = new
MembershipUserWrapper(mu);
memberList.Add(md);
}
}
if (sortData == null)
{
sortData = "UserName";
}
if (sortData.Length == 0)
{
sortData = "UserName";
}
// Make a special version of sortData for the switch
statement so that whether or not the
// DESC is appended to the string sortData, it will
switch on the base of that string.
string sortDataBase = sortData; // init and assume
there is not DESC appended to sortData
string descString = " DESC";
if (sortData.EndsWith(descString))
{
sortDataBase = sortData.Substring(0,
sortData.Length - descString.Length);
}
Comparison<MembershipUserWrapper> comparison = null;
switch (sortDataBase)
{
case "UserName":
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
return
lhs.UserName.CompareTo(rhs.UserName);
}
);
break;
case "Email":
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
if (lhs.Email == null | rhs.Email ==
null)
{
return 0;
}
else
{
return
lhs.Email.CompareTo(rhs.Email);
}
}
);
break;
case "CreationDate":
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
return
lhs.CreationDate.CompareTo(rhs.CreationDate);
}
);
break;
case "IsApproved":
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
return
lhs.IsApproved.CompareTo(rhs.IsApproved);
}
);
break;
case "IsOnline":
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
return
lhs.IsOnline.CompareTo(rhs.IsOnline);
}
);
break;
case "LastLoginDate":
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
return
lhs.LastLoginDate.CompareTo(rhs.LastLoginDate);
}
);
break;
default:
comparison = new
Comparison<MembershipUserWrapper>(
delegate(MembershipUserWrapper lhs,
MembershipUserWrapper rhs)
{
return
lhs.UserName.CompareTo(rhs.UserName);
}
);
break;
}
if (sortData.EndsWith("DESC"))
{
memberList.Sort(comparison);
memberList.Reverse();
}
else
{
memberList.Sort(comparison);
}
}
// FxCopy will give us a warning about returning a List
rather than a Collection.
// We could copy the data, but not worth the trouble.
return memberList;
}
}
}
************************************************** **End of C#
code***********************************
********************************************and the equivalent VB.NET
code ***********************
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Globalization
Imports System.Collections.ObjectModel
Namespace MembershipUtilities
' <summary>
' Class Used to Select, Update, Insert and Delete
' From the Microsoft ASP.NET Membership API
' </summary>
'
'Class This attribute allows the ObjectDataSource wizard to see
this class
<DataObject(True)> _
Public Class MembershipUserODS
' <summary>
' This insert method is the default insert method. It is
typically associated with
' a detailview control for inserting new members.
' </summary>
' <param name="userName">MembershipUser.UserName</param>
' <param name="password">MembershipUser.password</param>
' <param name="isApproved">MembershipUser.IsApproved</param>
' <param name="comment">MembershipUser.comment</param>
' <param
name="lastLockoutDate">MembershipUser.lastLockoutD ate</param>
' <param
name="creationDate">MembershipUser.creationDate</param>
' <param name="email">MembershipUser.email</param>
' <param
name="lastActivityDate">MembershipUser.lastActivit yDate</param>
' <param
name="providerName">MembershipUser.providerName</param>
' <param name="isLockedOut">MembershipUser.isLockedOut</param>
' <param
name="lastLoginDate">MembershipUser.lastLoginDate</param>
' <param name="isOnline">MembershipUser.isOnline</param>
' <param
name="passwordQuestion">MembershipUser.passwordQue stion</param>
' <param
name="lastPasswordChangedDate">MembershipUser.last PasswordChangedDate</param>
'
<DataObjectMethod(DataObjectMethodType.Insert, True)> _
Public Shared Sub Insert(ByVal userName As String, ByVal
isApproved As Boolean, ByVal comment As String, ByVal lastLockoutDate
As DateTime, ByVal creationDate As DateTime, ByVal email As String,
ByVal lastActivityDate As DateTime, ByVal providerName As String, ByVal
isLockedOut As Boolean, ByVal lastLoginDate As DateTime, ByVal isOnline
As Boolean, ByVal passwordQuestion As String, ByVal
lastPasswordChangedDate As DateTime, ByVal password As String, ByVal
passwordAnswer As String)
' The incoming parameters, password and passwordAnswer are
not properties of the
' MembershipUser class. Membership has special member
functions to deal with these
' two special properties for security reasons. For this
reason, they do not appear
' in a datacontrol that is created with this user object.
'
' the only reason you may want to have defaults is so you
can build insert into your
' datacontrol. A better approach would be to either follow
the example shown in the
' Membership.asp page where the parameters are set directly
to the userobject, or not
' include "new" at all in your control and use the other
controls in the Membership API
' for creating new members. (CreateUserWizard, etc)
'
' It is recommended that you only enable the following
lines if you are sure of what you are doing
'if (password == null)
'{
' password = "pass0word";
'}
'if (passwordAnswer == null)
'{
' passwordAnswer = "Password Answer";
'}
Dim status As MembershipCreateStatus
Membership.CreateUser(userName, password, email,
passwordQuestion, passwordAnswer, isApproved, status)
If (status <> MembershipCreateStatus.Success) Then
Throw New ApplicationException(status.ToString)
End If
Dim mu As MembershipUser = Membership.GetUser(userName)
mu.Comment = comment
Membership.UpdateUser(mu)
End Sub
' <summary>
' Takes as input the original username and the current username
' </summary>
' <param name="providerUserKey"></param>
' <param name="Original_providerUserKey"></param>
'
<DataObjectMethod(DataObjectMethodType.Delete, True)> _
Public Shared Sub Delete(ByVal UserName As String)
Membership.DeleteUser(UserName, True)
End Sub
' <summary>
' This update method is the default update as shown by the
class attribute.
'
' </summary>
' <param name="original_UserName">MembershipUser.UserName
originally retrieved</param>
' <param name="email">MembershipUser.email</param>
' <param name="isApproved">MembershipUser.isApproved</param>
' <param name="comment">MembershipUser.comment</param>
' <param name="password">MembershipUser.password</param>
' <param
name="passwordAnswer">MembershipUser.passwordAnswe r</param>
' <param
name="lastActivityDate">MembershipUser.lastActivit yDate</param>
' <param
name="lastLoginDate">MembershipUser.lastLoginDate</param>
'
<DataObjectMethod(DataObjectMethodType.Update, True)> _
Public Overloads Shared Sub Update(ByVal UserName As String,
ByVal email As String, ByVal isApproved As Boolean, ByVal comment As
String, ByVal lastActivityDate As DateTime, ByVal lastLoginDate As
DateTime)
Dim dirtyFlag As Boolean = False
Dim mu As MembershipUser = Membership.GetUser(UserName)
If ((mu.Comment = Nothing) _
OrElse (mu.Comment.CompareTo(comment) <> 0))
Then
dirtyFlag = True
mu.Comment = comment
End If
If ((mu.Email = Nothing) _
OrElse (mu.Email.CompareTo(email) <> 0)) Then
dirtyFlag = True
mu.Email = email
End If
If (mu.IsApproved <> isApproved) Then
dirtyFlag = True
mu.IsApproved = isApproved
End If
If (dirtyFlag = True) Then
Membership.UpdateUser(mu)
End If
End Sub
' <summary>
' This is just used to set the IsApproved status.
' username is always passed in for searching purposes.
' </summary>
' <param name="original_username">Current UserName to Update
(primary key)</param>
' <param name="isApproved">MembershipUser.isApproved</param>
'
<DataObjectMethod(DataObjectMethodType.Update, False)> _
Public Overloads Shared Sub Update(ByVal Username As String,
ByVal isApproved As Boolean)
Dim dirtyFlag As Boolean = False
Dim mu As MembershipUser = Membership.GetUser(Username)
If (mu.IsApproved <> isApproved) Then
dirtyFlag = True
mu.IsApproved = isApproved
End If
If (dirtyFlag = True) Then
Membership.UpdateUser(mu)
End If
End Sub
' <summary>
' Make a list of MembershipUserWrapper objects
' </summary>
' <returns>A List of type MembershipUserWrapper</returns>
'
<DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Overloads Shared Function GetMembers() As List
Return GetMembers(True, True, Nothing, Nothing)
End Function
' <summary>
' Make a list of MembershipUserWrapper objects by current sort
' </summary>
' <param name="sortData">Whicfh Column to perform the sort
on</param>
' <returns>A List of type MembershipUserWrapper</returns>
'
<DataObjectMethod(DataObjectMethodType.Select, True)> _
Public Overloads Shared Function GetMembers(ByVal sortData As
String) As List
' All Users, All approvalStatus
Return GetMembers(True, True, Nothing, sortData)
End Function
' <summary>
' returns all approved users by specified sort
' </summary>
' <param name="approvalStatus">if true, return approved
users</param>
' <param name="sortData">description of sort</param>
' <returns>A List of type MembershipUserWrapper</returns>
'
<DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Overloads Shared Function GetMembers(ByVal
approvalStatus As Boolean, ByVal sortData As String) As List
If (approvalStatus = True) Then
Return GetMembers(True, False, Nothing, sortData)
Else
Return GetMembers(False, True, Nothing, sortData)
End If
End Function
' <summary>
' Return a collection of MembershipUserWrapper's based on
criteria passed in as parameters
' </summary>
' <param name="returnAllApprovedUsers">returns all users with
approval set to true</param>
' <param name="returnAllNotApproviedUsers">return all users
with approval set to false</param>
' <param name="usernameToFind">return based on username
(overrides approval above)</param>
' <param name="sortData">sort parameter</param>
' <returns>Returns a Collection of Users (as recommended by
FxCop)</returns>
'
<DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Overloads Shared Function GetMembers(ByVal
returnAllApprovedUsers As Boolean, ByVal returnAllNotApprovedUsers As
Boolean, ByVal usernameToFind As String, ByVal sortData As String) As
List
Dim memberList As List = New List
' See if we are looking for just one user
If (Not (usernameToFind) Is Nothing) Then
Dim mu As MembershipUser =
Membership.GetUser(usernameToFind)
If (Not (mu) Is Nothing) Then
Dim md As MembershipUserWrapper = New
MembershipUserWrapper(mu)
memberList.Add(md)
End If
Else
Dim muc As MembershipUserCollection =
Membership.GetAllUsers
For Each mu As MembershipUser In muc
If (((returnAllApprovedUsers = True) _
AndAlso (mu.IsApproved = True)) _
OrElse ((returnAllNotApprovedUsers =
True) _
AndAlso (mu.IsApproved = False))) Then
Dim md As MembershipUserWrapper = New
MembershipUserWrapper(mu)
memberList.Add(md)
End If
Next
If (sortData = Nothing) Then
sortData = "UserName"
End If
If (sortData.Length = 0) Then
sortData = "UserName"
End If
' Make a special version of sortData for the switch
statement so that whether or not the
' DESC is appended to the string sortData, it will
switch on the base of that string.
Dim sortDataBase As String = sortData
' init and assume there is not DESC appended to
sortData
Dim descString As String = " DESC"
If sortData.EndsWith(descString) Then
sortDataBase = sortData.Substring(0,
(sortData.Length - descString.Length))
End If
Dim comparison As Comparison = Nothing
Select Case (sortDataBase)
Case "UserName"
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
Return lhs.UserName.CompareTo(rhs.UserName)
Case "Email"
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
If ((lhs.Email = Nothing) _
Or (rhs.Email = Nothing)) Then
Return 0
Else
Return lhs.Email.CompareTo(rhs.Email)
End If
Case "CreationDate"
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
Return
lhs.CreationDate.CompareTo(rhs.CreationDate)
Case "IsApproved"
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
Return lhs.IsApproved.CompareTo(rhs.IsApproved)
Case "IsOnline"
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
Return lhs.IsOnline.CompareTo(rhs.IsOnline)
Case "LastLoginDate"
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
Return
lhs.LastLoginDate.CompareTo(rhs.LastLoginDate)
Case Else
comparison = New Comparison(delegate,
MembershipUserWrapper, lhs, MembershipUserWrapper, rhs)
Return lhs.UserName.CompareTo(rhs.UserName)
End Select
If sortData.EndsWith("DESC") Then
memberList.Sort(comparison)
memberList.Reverse()
Else
memberList.Sort(comparison)
End If
End If
' FxCopy will give us a warning about returning a List
rather than a Collection.
' We could copy the data, but not worth the trouble.
Return memberList
End Function
''****************************************This is your code
***************************************
'Delegate Function Comparison(Of T)(ByVal lhs As T, ByVal rhs
As T) As Integer
''our example class
'Class MembershipUserWrapper
' ' a datetime attribute for it, wrapped in a property as
usual
' Private creationDateValue As DateTime
' Public Property CreationDate() As DateTime
' Get
' Return creationDateValue
' End Get
' Set(ByVal value As DateTime)
' creationDateValue = value
' End Set
' End Property
' ' the class method for comparing two instances of the
class
' Public Shared Function Compare(ByVal x As
MembershipUserWrapper, ByVal y As MembershipUserWrapper) As Integer
' Return
x.creationDateValue.CompareTo(y.creationDateValue)
' End Function
'End Class
'Sub Main()
' 'the result of the comparison
' Dim compar As Integer
' 'the two objects we are comparing
' Dim lhs, rhs As MembershipUserWrapper
' 'create a comparison delegate that invokes
' 'the class' comparison method
' 'and pass this new delegate the two objects to compare
' compar = (New Comparison(Of MembershipUserWrapper) _
' (AddressOf MembershipUserWrapper.Compare)) _
' (lhs, rhs)
'End Sub
''************************************************ ******End of
your code*************************
End Class
End Namespace
********************************************End of VB.NET
code***************************************
Could you please help me with the right conversion.
Thanks
-L