Given the code below, what does the "with" keyword do? I'm not very familiar with it, and I'm not sure of its purpose.
Sub NotePage_Load()
With Request.Form
Thanks Kevin
Given the code below, what does the "with" keyword do? I'm not very familiar with it, and I'm not sure of its purpose.
Sub NotePage_Load()
With Request.Form
Thanks Kevin
With is the equivalent of adding Request.Form
before any references in the with block.
With Request.Form
Dim count as int = .Count
End With
versus:
Dim count as int = Request.Form.Count
With
allows you to omit the part after the with and just use the dot operator - .
to access properties, members and methods.
Well it acts as an alias to Request.Form
So you don't need to do
Request.Form.this
or
Request.Form.this
you can just do
this
or
that
It's a shorthand... everything within the With..End With block will be treated as if something is appended in front of it.
Ex:
With Request.Form
["xxx"] = "yyy"
["aaa"] = "bbb"
End With
is equal to the following:
Request.Form["xxx"] = "yyy"
Request.Form["aaa"] = "bbb"