Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:55:08+00:00 2026-06-11T06:55:08+00:00

In C#, a property’s setter value keyword will automatically be same as the property’s

  • 0

In C#, a property’s setter value keyword will automatically be same as the property’s type.

For example, in C# ,type of value is string

private string str = string.Empty;
public string MyText 
{
    get { return str; }
    set { str = value; }
}

If we convert this snippet to VB.Net we get

Private str As String = String.Empty
Public Property MyText() As String
    Get
        Return str 
    End Get
    Set(ByVal value As String)
        str = value
    End Set
End Property

Questions

  1. Why does set have this line Set(ByVal value As String)? Shouldn’t value type
    automatically be String. This way.

    Private str As String = String.Empty
    Public Property MyText() As String
        Get
            Return str 
        End Get
        Set
            str = value
        End Set
    End Property
    

    What’s the use of that?

  2. I cannot change BYVal to ByRef (I tried, it gives error), then what’s use of that also?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:55:09+00:00Added an answer on June 11, 2026 at 6:55 am

    You can omit the (ByVal value As String) part. Visual Studio will keep adding it, but it is not required by either the language nor the compiler.

    You can use a parameter name other than value. Also note that since VS2010 SP1, you can omit the ByVal keyword.


    Example:

    Class Test
    
        Private str As String = String.Empty
    
        Public Property MyText() As String
            Get
                Return str 
            End Get
            Set
                str = value
            End Set
        End Property
    
        Public Property MyText2() As String
            Get
                Return str 
            End Get
            Set(something As String)
                str = something
            End Set
        End Property
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

set value of a property of an anonymous type using reflection / TypeDescriptor is
property curRefID: public string curRefID { get { return ViewState [curid] as string; }
Property 'Latitude' is a scalar type on class 'LatitudeLongitude'. Cannot generate a setter method
property type UIModalTransitionStyle is incompatible with type UIModalTransitionStyle inherited from UIViewController Getting the above
Property in UserControl: public JobQuote quote { get { if (ViewState[Quote] != null) return
Possible Duplicate: Difference between Property and Field in C# public class Test { public
I have a custom property in Episerver inherited from LongString. The value of property
@property (atomic, retain) NSArray *array; I don't override a setter and a getter of
When creating a property to correspond to an Oracle column of type NUMBER(6, 3),
I have a Let property defined as: Public Property Let Set_ChanArray_Enabled1(i As Integer, j

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.