convert small class from vb.net to c#

I have isolated the following items but mostly need your help on items 3, 4, and 5:

'<<<<<<<<<<<<<<<<<<<< how to start and end region in C# <<<<<<<<<<<<<<<<<<<<<<<<<   item: 3
'<<<<<<<<<<<<<<<<<<<< how to code get and set in C# <<<<<<<<<<<<<<<<<<<<<<<<<<<<   item: 4
'<<<<<<<<<<<<<<<<<<<< how to code constructor in C# <<<<<<<<<<<<<<<<<<<<<<<<<<<<   item: 5

Question: Could you show me how to convert this class to run in c#?

Thank you.
Imports Microsoft.VisualBasic
''' <summary> 
''' CriteriaCollection class  
''' Author: M. 
''' Date: 3-16-2014
''' </summary>
''' <remarks>Project: xyz</remarks>
Public Class CriteriaCollection

'<<<<<<<<<<<<<<<<<<<< how to start and end region in C# <<<<<<<<<<<<<<<<<<   item: 3
#Region "Class Variables "    
    Private _regionId As long
    Private _metricId As long
    Private _yyyy As String
#End Region

#Region "Properties"

'<<<<<<<<<<<<<<<<<<<< how to code get and set in C# <<<<<<<<<<<<<<<<<<   item: 4
    Public Property RegionId() As long
        Get
            Return _regionId
        End Get
        Set(value As long)
            _regionId = value
        End Set
    End Property

    Public Property MetricId() As long
        Get
            Return _metricId
        End Get
        Set(value As long)
            _metricId = value
        End Set
    End Property

    Public Property YYYY() As String
        Get
            Return _yyyy
        End Get
        Set(value As String)
            _yyyy = value
        End Set
    End Property

#End Region

#Region " Constructors "

    ''' <summary>
    ''' Empty constructor
    ''' </summary>
    ''' <remarks>Properties to be updated after instantiation</remarks>
	
	'<<<<<<<<<<<<<<<<<<<< how to code constructor in C# <<<<<<<<<<<<<<<<<<   item: 5
    Public Sub New()
        '*** empty sub new 
    End Sub

    ''' <summary>
    ''' Constructor to create a new CriteriaObject with all properies assigned
    ''' </summary>
    ''' <param name="regionId">Region ID </param>
    ''' <param name="MetricId">Metric ID</param>
    ''' <param name="email">YYYY string</param>
    ''' <remarks></remarks>
    Public Sub New(ByVal regionId As long, ByVal metricId As long, ByVal yyyy As String)

        _regionId = regionId
        _metricId = metricId
        _yyyy = yyyy

    End Sub

#End Region

End Class

Open in new window

LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
There are online code converters that you can use for such tasks.

e.g.


using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
/// <summary> 
/// CriteriaCollection class  
/// Author: M. 
/// Date: 3-16-2014
/// </summary>
/// <remarks>Project: xyz</remarks>
//<<<<<<<<<<<<<<<<<<<<<<<<<<namespace ASPChartComparision required in C#  <<<<<<<<<<<<<<<<<<   item: 2
public class CriteriaCollection
{

	//<<<<<<<<<<<<<<<<<<<< how to start and end region in C# <<<<<<<<<<<<<<<<<<   item: 3
	#region "Class Variables "
	private long _regionId;
	private long _metricId;
		#endregion
	private string _yyyy;

	#region "Properties"

	//<<<<<<<<<<<<<<<<<<<< how to code get and set in C# <<<<<<<<<<<<<<<<<<   item: 4
	public long RegionId {
		get { return _regionId; }
		set { _regionId = value; }
	}

	public long MetricId {
		get { return _metricId; }
		set { _metricId = value; }
	}

	public string YYYY {
		get { return _yyyy; }
		set { _yyyy = value; }
	}

	#endregion

	#region " Constructors "

	/// <summary>
	/// Empty constructor
	/// </summary>
	/// <remarks>Properties to be updated after instantiation</remarks>

//<<<<<<<<<<<<<<<<<<<< how to code constructor in C# <<<<<<<<<<<<<<<<<<   item: 5
	public CriteriaCollection()
	{
		//*** empty sub new 
	}

	/// <summary>
	/// Constructor to create a new CriteriaObject with all properies assigned
	/// </summary>
	/// <param name="regionId">Region ID </param>
	/// <param name="MetricId">Metric ID</param>
	/// <param name="email">YYYY string</param>
	/// <remarks></remarks>

	public CriteriaCollection(long regionId, long metricId, string yyyy)
	{
		_regionId = regionId;
		_metricId = metricId;
		_yyyy = yyyy;

	}

	#endregion

}
//<<<<<<<<<<<<<<<<<<<<<<<<<< I suppose, in C#,  we close namespace by adding } at the end  <<<<<<<<<<<<<<<<<<   item: 6

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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you for the link. I will keep it handy. Digging into it I got the following which seems very easily done in C#.

I would appreciate a brief comment and a sanity check on my version of the code below:
// <summary>  
namespace SetCriteriaCollection
{
	public class CriteriaCollection
	{
		public int RegionId {get; set;}
		public int MetricId {get; set;}
		public string YYYY {get; set;}
		public SetCriteriaCollection(int regionId, int metricId, string yyyy)
		{
			RegionId=regionId;
			MetricId=metricId;
			YYYY=yyyy;
		}
	}
}

Open in new window


Mike
0
käµfm³d 👽Commented:
Other than you changed the data types from long to int and the name of the method from CriteriaCollection to SetCriteriaCollection, it appears to be the same. You're using auto-implemented properties rather than having a backing field, but there's nothing wrong with that.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Mike EghtebasDatabase and Application DeveloperAuthor Commented:
CriteriaCollection is the class but
SetCriteriaCollection is the name for namespace
I thought namespace ought to be a bit different.

For your information, the subject of my next post will be "how to use CriteriaCollection class to have 4 set criteria collection stored.

I suppose, I better change my class name to RODcriteria and then not to confuse myself when I am working with collection object.

Thanky you for you help.

Mie
0
käµfm³d 👽Commented:
CriteriaCollection is the class but
SetCriteriaCollection is the name for namespace
Oh, then I read your code wrong. A namespace is nothing more than a container--it's not executable code. So really the name of that "method" is wrong. That is supposed to be the constructor (which in this case takes parameters). Constructors should be named the same as the class they construct, not the namespace.
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.