|
-
Sep 25th, 2006, 03:38 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] help (very simple)
i know i know i should know this
but how can you do a "with"
example in vb would be
with OFD_open
.something
.somethingelse
end with
i have no idea how to do this in c# and everything i try to seach on doesnt want to search the word "with" becuase its joiner word
-
Sep 25th, 2006, 03:42 PM
#2
Re: help (very simple)
Ah, sorry, I misunderstood the question.
There is no 'With' in C#.
-
Sep 25th, 2006, 04:47 PM
#3
Thread Starter
Fanatic Member
Re: help (very simple)
well then
im not crazy after all
or not becuase of this anyway
thanks
-
Sep 25th, 2006, 06:01 PM
#4
Re: help (very simple)
Let's not forget to resolve our threads.
"With" in VB doesn't really do anything that can't be done very easily without it. There are only two valid reasons to use a "With" statement in VB:
1. You want to get a single reference via a long chain, e.g.
VB Code:
myDataAdapter.SelectCommand.Parameters.AddWithValue("@Paramater1", myTextBox1.Text)
myDataAdapter.SelectCommand.Parameters.AddWithValue("@Paramater2", myTextBox2.Text)
becomes:
VB Code:
With myDataAdapter.SelectCommand.Parameters
.AddWithValue("@Paramater1", myTextBox1.Text)
.AddWithValue("@Paramater2", myTextBox2.Text)
End With
so that myDataAdapter.SelectCommand.Parameters gets evaluated only once. This can be mimicked using a local variable with only slightly more code.
2. You want to access multiple members of the same variable without typing the variable name multiple times. This is mostly negated by the fact that C# Intellisense kicks in as soon as you start typing, although you can prompt VB Intellisense with Ctrl+Space anyway.
The "With" statement is intended to make code easier to read but many people misuse it and it actually has the opposite affect. Any dots not at the beginning of a line are actually harder to see, so to use a With block like this:
VB Code:
With myTextBox
.Text = "Hello World"
MessageBox.Show(.Text)
End With
would be considered bad coding style.
-
Sep 25th, 2006, 08:15 PM
#5
Thread Starter
Fanatic Member
Re: help (very simple)
yea i just didnt want to type it in over and over.
i just put it on the clipboard and did it that way
-
Sep 25th, 2006, 08:39 PM
#6
Re: help (very simple)
So... this thread is resolved, correct?
-
Sep 26th, 2006, 04:13 PM
#7
Re: help (very simple)
Correct.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|