Write a property on one line

  • Thread starter Thread starter kurt sune
  • Start date Start date
K

kurt sune

If I want to write this in one line; how do I achieve it?

Public Property x1() As Integer

Get

Return _x1

End Get

Set(ByVal Value As Integer)

_x1 = Value

End Set

End Property



/k
 
Kurt,

You can create a C# class and use that than in your project.

One of by some found bad things of VB languages is that the VBCrLf has a
kind of same meaning as in C languages the " ;"

I prefer it by the way over everytime typing the ";"

Just my thought,

Cor
 
I'm curious because I've never seen the _x1. It appears as if you have
dimensioned x1 as an array of integers. What does the property x1() return?
Would appreciate any help you can give me to understand this. Thanks.
 
Dennis said:
I'm curious because I've never seen the _x1. It appears as if you have
dimensioned x1 as an array of integers. What does the property x1()
return?
Would appreciate any help you can give me to understand this. Thanks.

You can make the property return a whole integer array:

\\\
Private m_X() As Integer
..
..
..
Public Property X() As Integer()
Get
Return m_X
End Get
Set(ByVal Value() As Integer)
m_X = Value
End Set
End Property
///
 
Thanks. Then does the following work and if so, is xcopy a deep copy or
shallow copy?

dim x() as integer
dim xcopy() as integer

xcopy = _x
'or
_xcopy=x
 
Dennis said:
Then does the following work and if so, is xcopy a deep copy or
shallow copy?

dim x() as integer
dim xcopy() as integer

xcopy = _x
'or
_xcopy=x

Arrays are reference types, both variables will point to the same array
afterwards.
 
Herfried,
Arrays are reference types, both variables will point to the same array
afterwards.
I think that you have to explain that "afterwards" now they both reference
to nothing.

Cor
 
Cor Ligthert said:
I think that you have to explain that "afterwards" now they both reference
to nothing.

I assumed the OP uses code similar to this:

\\\
Dim a1() As Integer = {1, 2, 3}
Dim a2() As Integer = a1
a2(1) = 99
MsgBox(CStr(a1(1)))
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top