A = b = 5 in VB.NET - impossible?

Is it possible to do in VB.NET a = b = 5? (I know the =comparison operator too)

I do not mean the result (if, for example, b = 2)

a = false
b = 2

HOW to do this, however, in situations like below?


The inconvenience caused this question in my code: some objects a, b, .. zare passed by the ref method in the method, if I do not initialize them, the compiler warns me that it will be initialized (= Nothing, for example.)

Dim a, b, c, d, z As GraphicsPath ' = Nothing is impossible, only each a part
DrawPaths(a, b, c, d, z)          ' DrawPaths sets a = new GraphicPath() etc. 
+3
source share
3 answers

a = b = 5 means

if b = 5 then a = true else a = false

if you want to assign the values ​​5 a and b at the same time, you must add it on a separate line:

b = 5
a = b

, vb.net:

b = 5 : a = b
+8

= VB/VB.NET , .

+5

These are just the rules of the base language. Many languages ​​use different operators to distinguish between analysis and equality analysis.

For instance,

  • C / C ++ / C # / Java uses =and ==.
  • Pascal uses :=and =.
  • The main one is not.
+2
source

Source: https://habr.com/ru/post/1727754/


All Articles