Avatar of adamtrask
adamtrask

asked on 

Learning C# (How to create a class)

Hello Experts,

I am taking the plunge into C# after acquiring a reasonable knowledge of VB.Net.

I am trying to declare a strongly typed string List in a new class:

Below is how I wrote it in VB.Net and I need some one to translate into C# the initial few lines:


Thanks
Public Class ListsDB
    Private _myCallsList As New List(Of String)
    Private _myTestList As New List(Of String)
    Private _myVisitsList As New List(Of String)
    Public Property MyCallsList() As List(Of String)
        Get
            Return _myCallsList
        End Get
        Set(ByVal value As List(Of String))
            _myCallsList = value
        End Set
    End Property
    Public Property MyTestList() As List(Of String)
        Get
            Return _myTestList
        End Get
        Set(ByVal value As List(Of String))
            _myTestList = value
        End Set
    End Property
    Public Property myVisitsList() As List(Of String)
        Get
            Return _myVisitsList
        End Get
        Set(ByVal value As List(Of String))
            _myVisitsList = value
        End Set
    End Property

Open in new window

ASP.NETC#Visual Basic.NET

Avatar of undefined
Last Comment
adamtrask
ASKER CERTIFIED SOLUTION
Avatar of saragani
saragani

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of brutaldev
brutaldev
Flag of South Africa image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of saragani
saragani

Oops, I forgot the rest of the public properties, but I assume you got the idea.

In VB its:
private something as TypeOfSomething
or
private something as New TypeOfSomething()


and in C# it's:
private TypeOfSomething something;
or
private TypeOfSomething something = new TypeOfSomething();

and not forget the ;


For registering events for example:

button1.Click += ....


if you click Tab twice after the += then it also auto completes you with needed text and also creates an empty event handler.
Avatar of adamtrask
adamtrask

ASKER

Thank you guys
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo